You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2010 lines
65 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_rcc_ex.c
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 29-January-2016
  7. * @brief Extended RCC HAL module driver.
  8. * This file provides firmware functions to manage the following
  9. * functionalities RCC extended peripheral:
  10. * + Extended Peripheral Control functions
  11. *
  12. ******************************************************************************
  13. * @attention
  14. *
  15. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are permitted provided that the following conditions are met:
  19. * 1. Redistributions of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  25. * may be used to endorse or promote products derived from this software
  26. * without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  29. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  32. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  34. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  35. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  36. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  37. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. ******************************************************************************
  40. */
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal.h"
  43. /** @addtogroup STM32L4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @defgroup RCCEx RCCEx
  47. * @brief RCC Extended HAL module driver
  48. * @{
  49. */
  50. #ifdef HAL_RCC_MODULE_ENABLED
  51. /* Private typedef -----------------------------------------------------------*/
  52. /* Private defines -----------------------------------------------------------*/
  53. /** @defgroup RCCEx_Private_Constants RCCEx Private Constants
  54. * @{
  55. */
  56. #define PLLSAI1_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  57. #define PLLSAI2_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  58. #define PLL_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  59. #define __LSCO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
  60. #define LSCO_GPIO_PORT GPIOA
  61. #define LSCO_PIN GPIO_PIN_2
  62. /**
  63. * @}
  64. */
  65. /* Private macros ------------------------------------------------------------*/
  66. /* Private variables ---------------------------------------------------------*/
  67. /* Private function prototypes -----------------------------------------------*/
  68. /** @defgroup RCCEx_Private_Functions RCCEx Private Functions
  69. * @{
  70. */
  71. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNP(RCC_PLLSAI1InitTypeDef *PllSai1);
  72. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNQ(RCC_PLLSAI1InitTypeDef *PllSai1);
  73. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNR(RCC_PLLSAI1InitTypeDef *PllSai1);
  74. static HAL_StatusTypeDef RCCEx_PLLSAI2_ConfigNP(RCC_PLLSAI2InitTypeDef *PllSai2);
  75. static HAL_StatusTypeDef RCCEx_PLLSAI2_ConfigNR(RCC_PLLSAI2InitTypeDef *PllSai2);
  76. /**
  77. * @}
  78. */
  79. /* Exported functions --------------------------------------------------------*/
  80. /** @defgroup RCCEx_Exported_Functions RCCEx Exported Functions
  81. * @{
  82. */
  83. /** @defgroup RCCEx_Exported_Functions_Group1 Extended Peripheral Control functions
  84. * @brief Extended Peripheral Control functions
  85. *
  86. @verbatim
  87. ===============================================================================
  88. ##### Extended Peripheral Control functions #####
  89. ===============================================================================
  90. [..]
  91. This subsection provides a set of functions allowing to control the RCC Clocks
  92. frequencies.
  93. [..]
  94. (@) Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to
  95. select the RTC clock source; in this case the Backup domain will be reset in
  96. order to modify the RTC Clock source, as consequence RTC registers (including
  97. the backup registers) and RCC_BDCR register are set to their reset values.
  98. @endverbatim
  99. * @{
  100. */
  101. /**
  102. * @brief Initialize the RCC extended peripherals clocks according to the specified
  103. * parameters in the RCC_PeriphCLKInitTypeDef.
  104. * @param PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that
  105. * contains a field PeriphClockSelection which can be a combination of the following values:
  106. * @arg @ref RCC_PERIPHCLK_RTC RTC peripheral clock
  107. * @arg @ref RCC_PERIPHCLK_ADC ADC peripheral clock
  108. * @arg @ref RCC_PERIPHCLK_DFSDM DFSDM peripheral clock
  109. * @arg @ref RCC_PERIPHCLK_I2C1 I2C1 peripheral clock
  110. * @arg @ref RCC_PERIPHCLK_I2C2 I2C2 peripheral clock
  111. * @arg @ref RCC_PERIPHCLK_I2C3 I2C3 peripheral clock
  112. * @arg @ref RCC_PERIPHCLK_LPTIM1 LPTIM1 peripheral clock
  113. * @arg @ref RCC_PERIPHCLK_LPTIM2 LPTIM2 peripheral clock
  114. * @arg @ref RCC_PERIPHCLK_LPUART1 LPUART1 peripheral clock
  115. * @arg @ref RCC_PERIPHCLK_RNG RNG peripheral clock
  116. * @arg @ref RCC_PERIPHCLK_SAI1 SAI1 peripheral clock
  117. * @arg @ref RCC_PERIPHCLK_SAI2 SAI2 peripheral clock
  118. * @arg @ref RCC_PERIPHCLK_SDMMC1 SDMMC1 peripheral clock
  119. * @arg @ref RCC_PERIPHCLK_SWPMI1 SWPMI1 peripheral clock
  120. * @arg @ref RCC_PERIPHCLK_USART1 USART1 peripheral clock
  121. * @arg @ref RCC_PERIPHCLK_USART2 USART1 peripheral clock
  122. * @arg @ref RCC_PERIPHCLK_USART3 USART1 peripheral clock
  123. * @arg @ref RCC_PERIPHCLK_UART4 USART1 peripheral clock
  124. * @arg @ref RCC_PERIPHCLK_UART5 USART1 peripheral clock
  125. * @arg @ref RCC_PERIPHCLK_USB USB peripheral clock (only for devices with USB)
  126. *
  127. * @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
  128. * the RTC clock source: in this case the access to Backup domain is enabled.
  129. *
  130. * @retval HAL status
  131. */
  132. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
  133. {
  134. uint32_t tmpregister = 0;
  135. uint32_t tickstart = 0U;
  136. HAL_StatusTypeDef ret = HAL_OK; /* Intermediate status */
  137. HAL_StatusTypeDef status = HAL_OK; /* Final status */
  138. /* Check the parameters */
  139. assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection));
  140. /*-------------------------- SAI1 clock source configuration ---------------------*/
  141. if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI1) == RCC_PERIPHCLK_SAI1))
  142. {
  143. /* Check the parameters */
  144. assert_param(IS_RCC_SAI1CLK(PeriphClkInit->Sai1ClockSelection));
  145. switch(PeriphClkInit->Sai1ClockSelection)
  146. {
  147. case RCC_SAI1CLKSOURCE_PLL: /* PLL is used as clock source for SAI1*/
  148. /* Enable SAI Clock output generated form System PLL . */
  149. __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL_SAI3CLK);
  150. /* SAI1 clock source config set later after clock selection check */
  151. break;
  152. case RCC_SAI1CLKSOURCE_PLLSAI1: /* PLLSAI1 is used as clock source for SAI1*/
  153. /* PLLSAI1 parameters N & P configuration and clock output (PLLSAI1ClockOut) */
  154. ret = RCCEx_PLLSAI1_ConfigNP(&(PeriphClkInit->PLLSAI1));
  155. /* SAI1 clock source config set later after clock selection check */
  156. break;
  157. case RCC_SAI1CLKSOURCE_PLLSAI2: /* PLLSAI2 is used as clock source for SAI1*/
  158. /* PLLSAI2 parameters N & P configuration and clock output (PLLSAI2ClockOut) */
  159. ret = RCCEx_PLLSAI2_ConfigNP(&(PeriphClkInit->PLLSAI2));
  160. /* SAI1 clock source config set later after clock selection check */
  161. break;
  162. case RCC_SAI1CLKSOURCE_PIN: /* External clock is used as source of SAI1 clock*/
  163. /* SAI1 clock source config set later after clock selection check */
  164. break;
  165. default:
  166. ret = HAL_ERROR;
  167. break;
  168. }
  169. if(ret == HAL_OK)
  170. {
  171. /* Set the source of SAI1 clock*/
  172. __HAL_RCC_SAI1_CONFIG(PeriphClkInit->Sai1ClockSelection);
  173. }
  174. else
  175. {
  176. /* set overall return value */
  177. status = ret;
  178. }
  179. }
  180. /*-------------------------- SAI2 clock source configuration ---------------------*/
  181. if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI2) == RCC_PERIPHCLK_SAI2))
  182. {
  183. /* Check the parameters */
  184. assert_param(IS_RCC_SAI2CLK(PeriphClkInit->Sai2ClockSelection));
  185. switch(PeriphClkInit->Sai2ClockSelection)
  186. {
  187. case RCC_SAI2CLKSOURCE_PLL: /* PLL is used as clock source for SAI2*/
  188. /* Enable SAI Clock output generated form System PLL . */
  189. __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL_SAI3CLK);
  190. /* SAI2 clock source config set later after clock selection check */
  191. break;
  192. case RCC_SAI2CLKSOURCE_PLLSAI1: /* PLLSAI1 is used as clock source for SAI2*/
  193. /* PLLSAI1 parameters N & P configuration and clock output (PLLSAI1ClockOut) */
  194. ret = RCCEx_PLLSAI1_ConfigNP(&(PeriphClkInit->PLLSAI1));
  195. /* SAI2 clock source config set later after clock selection check */
  196. break;
  197. case RCC_SAI2CLKSOURCE_PLLSAI2: /* PLLSAI2 is used as clock source for SAI2*/
  198. /* PLLSAI2 parameters N & P configuration and clock output (PLLSAI2ClockOut) */
  199. ret = RCCEx_PLLSAI2_ConfigNP(&(PeriphClkInit->PLLSAI2));
  200. /* SAI2 clock source config set later after clock selection check */
  201. break;
  202. case RCC_SAI2CLKSOURCE_PIN: /* External clock is used as source of SAI2 clock*/
  203. /* SAI2 clock source config set later after clock selection check */
  204. break;
  205. default:
  206. ret = HAL_ERROR;
  207. break;
  208. }
  209. if(ret == HAL_OK)
  210. {
  211. /* Set the source of SAI2 clock*/
  212. __HAL_RCC_SAI2_CONFIG(PeriphClkInit->Sai2ClockSelection);
  213. }
  214. else
  215. {
  216. /* set overall return value */
  217. status = ret;
  218. }
  219. }
  220. /*-------------------------- RTC clock source configuration ----------------------*/
  221. if((PeriphClkInit->PeriphClockSelection & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
  222. {
  223. FlagStatus pwrclkchanged = RESET;
  224. /* Check for RTC Parameters used to output RTCCLK */
  225. assert_param(IS_RCC_RTCCLKSOURCE(PeriphClkInit->RTCClockSelection));
  226. /* Enable Power Clock */
  227. if(__HAL_RCC_PWR_IS_CLK_DISABLED())
  228. {
  229. __HAL_RCC_PWR_CLK_ENABLE();
  230. pwrclkchanged = SET;
  231. }
  232. /* Enable write access to Backup domain */
  233. SET_BIT(PWR->CR1, PWR_CR1_DBP);
  234. /* Wait for Backup domain Write protection disable */
  235. tickstart = HAL_GetTick();
  236. while((PWR->CR1 & PWR_CR1_DBP) == RESET)
  237. {
  238. if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
  239. {
  240. ret = HAL_TIMEOUT;
  241. break;
  242. }
  243. }
  244. if(ret == HAL_OK)
  245. {
  246. /* Reset the Backup domain only if the RTC Clock source selection is modified */
  247. if(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL) != PeriphClkInit->RTCClockSelection)
  248. {
  249. /* Store the content of BDCR register before the reset of Backup Domain */
  250. tmpregister = READ_BIT(RCC->BDCR, ~(RCC_BDCR_RTCSEL));
  251. /* RTC Clock selection can be changed only if the Backup Domain is reset */
  252. __HAL_RCC_BACKUPRESET_FORCE();
  253. __HAL_RCC_BACKUPRESET_RELEASE();
  254. /* Restore the Content of BDCR register */
  255. RCC->BDCR = tmpregister;
  256. }
  257. /* Wait for LSE reactivation if LSE was enable prior to Backup Domain reset */
  258. if (HAL_IS_BIT_SET(tmpregister, RCC_BDCR_LSERDY))
  259. {
  260. /* Get Start Tick*/
  261. tickstart = HAL_GetTick();
  262. /* Wait till LSE is ready */
  263. while(READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == RESET)
  264. {
  265. if((HAL_GetTick() - tickstart) > RCC_LSE_TIMEOUT_VALUE)
  266. {
  267. ret = HAL_TIMEOUT;
  268. break;
  269. }
  270. }
  271. }
  272. if(ret == HAL_OK)
  273. {
  274. /* Apply new RTC clock source selection */
  275. __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
  276. }
  277. else
  278. {
  279. /* set overall return value */
  280. status = ret;
  281. }
  282. }
  283. else
  284. {
  285. /* set overall return value */
  286. status = ret;
  287. }
  288. /* Restore clock configuration if changed */
  289. if(pwrclkchanged == SET)
  290. {
  291. __HAL_RCC_PWR_CLK_DISABLE();
  292. }
  293. }
  294. /*-------------------------- USART1 clock source configuration -------------------*/
  295. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_USART1) == RCC_PERIPHCLK_USART1)
  296. {
  297. /* Check the parameters */
  298. assert_param(IS_RCC_USART1CLKSOURCE(PeriphClkInit->Usart1ClockSelection));
  299. /* Configure the USART1 clock source */
  300. __HAL_RCC_USART1_CONFIG(PeriphClkInit->Usart1ClockSelection);
  301. }
  302. /*-------------------------- USART2 clock source configuration -------------------*/
  303. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_USART2) == RCC_PERIPHCLK_USART2)
  304. {
  305. /* Check the parameters */
  306. assert_param(IS_RCC_USART2CLKSOURCE(PeriphClkInit->Usart2ClockSelection));
  307. /* Configure the USART2 clock source */
  308. __HAL_RCC_USART2_CONFIG(PeriphClkInit->Usart2ClockSelection);
  309. }
  310. /*-------------------------- USART3 clock source configuration -------------------*/
  311. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_USART3) == RCC_PERIPHCLK_USART3)
  312. {
  313. /* Check the parameters */
  314. assert_param(IS_RCC_USART3CLKSOURCE(PeriphClkInit->Usart3ClockSelection));
  315. /* Configure the USART3 clock source */
  316. __HAL_RCC_USART3_CONFIG(PeriphClkInit->Usart3ClockSelection);
  317. }
  318. /*-------------------------- UART4 clock source configuration --------------------*/
  319. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_UART4) == RCC_PERIPHCLK_UART4)
  320. {
  321. /* Check the parameters */
  322. assert_param(IS_RCC_UART4CLKSOURCE(PeriphClkInit->Uart4ClockSelection));
  323. /* Configure the UART4 clock source */
  324. __HAL_RCC_UART4_CONFIG(PeriphClkInit->Uart4ClockSelection);
  325. }
  326. /*-------------------------- UART5 clock source configuration --------------------*/
  327. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_UART5) == RCC_PERIPHCLK_UART5)
  328. {
  329. /* Check the parameters */
  330. assert_param(IS_RCC_UART5CLKSOURCE(PeriphClkInit->Uart5ClockSelection));
  331. /* Configure the UART5 clock source */
  332. __HAL_RCC_UART5_CONFIG(PeriphClkInit->Uart5ClockSelection);
  333. }
  334. /*-------------------------- LPUART1 clock source configuration ------------------*/
  335. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LPUART1) == RCC_PERIPHCLK_LPUART1)
  336. {
  337. /* Check the parameters */
  338. assert_param(IS_RCC_LPUART1CLKSOURCE(PeriphClkInit->Lpuart1ClockSelection));
  339. /* Configure the LPUAR1 clock source */
  340. __HAL_RCC_LPUART1_CONFIG(PeriphClkInit->Lpuart1ClockSelection);
  341. }
  342. /*-------------------------- LPTIM1 clock source configuration -------------------*/
  343. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LPTIM1) == (RCC_PERIPHCLK_LPTIM1))
  344. {
  345. assert_param(IS_RCC_LPTIM1CLK(PeriphClkInit->Lptim1ClockSelection));
  346. __HAL_RCC_LPTIM1_CONFIG(PeriphClkInit->Lptim1ClockSelection);
  347. }
  348. /*-------------------------- LPTIM2 clock source configuration -------------------*/
  349. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LPTIM2) == (RCC_PERIPHCLK_LPTIM2))
  350. {
  351. assert_param(IS_RCC_LPTIM2CLK(PeriphClkInit->Lptim2ClockSelection));
  352. __HAL_RCC_LPTIM2_CONFIG(PeriphClkInit->Lptim2ClockSelection);
  353. }
  354. /*-------------------------- I2C1 clock source configuration ---------------------*/
  355. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2C1) == RCC_PERIPHCLK_I2C1)
  356. {
  357. /* Check the parameters */
  358. assert_param(IS_RCC_I2C1CLKSOURCE(PeriphClkInit->I2c1ClockSelection));
  359. /* Configure the I2C1 clock source */
  360. __HAL_RCC_I2C1_CONFIG(PeriphClkInit->I2c1ClockSelection);
  361. }
  362. /*-------------------------- I2C2 clock source configuration ---------------------*/
  363. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2C2) == RCC_PERIPHCLK_I2C2)
  364. {
  365. /* Check the parameters */
  366. assert_param(IS_RCC_I2C2CLKSOURCE(PeriphClkInit->I2c2ClockSelection));
  367. /* Configure the I2C2 clock source */
  368. __HAL_RCC_I2C2_CONFIG(PeriphClkInit->I2c2ClockSelection);
  369. }
  370. /*-------------------------- I2C3 clock source configuration ---------------------*/
  371. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2C3) == RCC_PERIPHCLK_I2C3)
  372. {
  373. /* Check the parameters */
  374. assert_param(IS_RCC_I2C3CLKSOURCE(PeriphClkInit->I2c3ClockSelection));
  375. /* Configure the I2C3 clock source */
  376. __HAL_RCC_I2C3_CONFIG(PeriphClkInit->I2c3ClockSelection);
  377. }
  378. #if defined(USB_OTG_FS)
  379. /*-------------------------- USB clock source configuration ----------------------*/
  380. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_USB) == (RCC_PERIPHCLK_USB))
  381. {
  382. assert_param(IS_RCC_USBCLKSOURCE(PeriphClkInit->UsbClockSelection));
  383. __HAL_RCC_USB_CONFIG(PeriphClkInit->UsbClockSelection);
  384. if(PeriphClkInit->UsbClockSelection == RCC_USBCLKSOURCE_PLL)
  385. {
  386. /* Enable PLL48M1CLK output */
  387. __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL_48M1CLK);
  388. }
  389. else if(PeriphClkInit->UsbClockSelection == RCC_USBCLKSOURCE_PLLSAI1)
  390. {
  391. /* PLLSAI1 parameters N & Q configuration and clock output (PLLSAI1ClockOut) */
  392. ret = RCCEx_PLLSAI1_ConfigNQ(&(PeriphClkInit->PLLSAI1));
  393. if(ret != HAL_OK)
  394. {
  395. /* set overall return value */
  396. status = ret;
  397. }
  398. }
  399. }
  400. #endif /* USB_OTG_FS */
  401. /*-------------------------- SDMMC1 clock source configuration -------------------*/
  402. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SDMMC1) == (RCC_PERIPHCLK_SDMMC1))
  403. {
  404. assert_param(IS_RCC_SDMMC1CLKSOURCE(PeriphClkInit->Sdmmc1ClockSelection));
  405. __HAL_RCC_SDMMC1_CONFIG(PeriphClkInit->Sdmmc1ClockSelection);
  406. if(PeriphClkInit->Sdmmc1ClockSelection == RCC_SDMMC1CLKSOURCE_PLL)
  407. {
  408. /* Enable PLL48M1CLK output */
  409. __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL_48M1CLK);
  410. }
  411. else if(PeriphClkInit->Sdmmc1ClockSelection == RCC_SDMMC1CLKSOURCE_PLLSAI1)
  412. {
  413. /* PLLSAI1 parameters N & Q configuration and clock output (PLLSAI1ClockOut) */
  414. ret = RCCEx_PLLSAI1_ConfigNQ(&(PeriphClkInit->PLLSAI1));
  415. if(ret != HAL_OK)
  416. {
  417. /* set overall return value */
  418. status = ret;
  419. }
  420. }
  421. }
  422. /*-------------------------- RNG clock source configuration ----------------------*/
  423. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RNG) == (RCC_PERIPHCLK_RNG))
  424. {
  425. assert_param(IS_RCC_RNGCLKSOURCE(PeriphClkInit->RngClockSelection));
  426. __HAL_RCC_RNG_CONFIG(PeriphClkInit->RngClockSelection);
  427. if(PeriphClkInit->RngClockSelection == RCC_RNGCLKSOURCE_PLL)
  428. {
  429. /* Enable PLL48M1CLK output */
  430. __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL_48M1CLK);
  431. }
  432. else if(PeriphClkInit->RngClockSelection == RCC_RNGCLKSOURCE_PLLSAI1)
  433. {
  434. /* PLLSAI1 parameters N & Q configuration and clock output (PLLSAI1ClockOut) */
  435. ret = RCCEx_PLLSAI1_ConfigNQ(&(PeriphClkInit->PLLSAI1));
  436. if(ret != HAL_OK)
  437. {
  438. /* set overall return value */
  439. status = ret;
  440. }
  441. }
  442. }
  443. /*-------------------------- ADC clock source configuration ----------------------*/
  444. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC)
  445. {
  446. /* Check the parameters */
  447. assert_param(IS_RCC_ADCCLKSOURCE(PeriphClkInit->AdcClockSelection));
  448. /* Configure the ADC interface clock source */
  449. __HAL_RCC_ADC_CONFIG(PeriphClkInit->AdcClockSelection);
  450. if(PeriphClkInit->AdcClockSelection == RCC_ADCCLKSOURCE_PLLSAI1)
  451. {
  452. /* PLLSAI1 parameters N & R configuration and clock output (PLLSAI1ClockOut) */
  453. ret = RCCEx_PLLSAI1_ConfigNR(&(PeriphClkInit->PLLSAI1));
  454. if(ret != HAL_OK)
  455. {
  456. /* set overall return value */
  457. status = ret;
  458. }
  459. }
  460. else if(PeriphClkInit->AdcClockSelection == RCC_ADCCLKSOURCE_PLLSAI2)
  461. {
  462. /* PLLSAI2 parameters N & R configuration and clock output (PLLSAI2ClockOut) */
  463. ret = RCCEx_PLLSAI2_ConfigNR(&(PeriphClkInit->PLLSAI2));
  464. if(ret != HAL_OK)
  465. {
  466. /* set overall return value */
  467. status = ret;
  468. }
  469. }
  470. }
  471. /*-------------------------- SWPMI1 clock source configuration -------------------*/
  472. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SWPMI1) == RCC_PERIPHCLK_SWPMI1)
  473. {
  474. /* Check the parameters */
  475. assert_param(IS_RCC_SWPMI1CLKSOURCE(PeriphClkInit->Swpmi1ClockSelection));
  476. /* Configure the SWPMI1 clock source */
  477. __HAL_RCC_SWPMI1_CONFIG(PeriphClkInit->Swpmi1ClockSelection);
  478. }
  479. /*-------------------------- DFSDM clock source configuration --------------------*/
  480. if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_DFSDM) == RCC_PERIPHCLK_DFSDM)
  481. {
  482. /* Check the parameters */
  483. assert_param(IS_RCC_DFSDMCLKSOURCE(PeriphClkInit->DfsdmClockSelection));
  484. /* Configure the DFSDM interface clock source */
  485. __HAL_RCC_DFSDM_CONFIG(PeriphClkInit->DfsdmClockSelection);
  486. }
  487. return status;
  488. }
  489. /**
  490. * @brief Get the RCC_ClkInitStruct according to the internal RCC configuration registers.
  491. * @param PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that
  492. * returns the configuration information for the Extended Peripherals
  493. * clocks(SAI1, SAI2, LPTIM1, LPTIM2, I2C1, I2C2, I2C3, LPUART,
  494. * USART1, USART2, USART3, UART4, UART5, RTC, ADCx, DFSDMx, SWPMI1, USB, SDMMC1 and RNG).
  495. * @retval None
  496. */
  497. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
  498. {
  499. /* Set all possible values for the extended clock type parameter------------*/
  500. #if defined(STM32L471xx)
  501. PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  502. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  503. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  504. RCC_PERIPHCLK_SDMMC1 | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_DFSDM | \
  505. RCC_PERIPHCLK_RTC ;
  506. #else
  507. PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  508. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  509. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | RCC_PERIPHCLK_USB | \
  510. RCC_PERIPHCLK_SDMMC1 | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_DFSDM | \
  511. RCC_PERIPHCLK_RTC ;
  512. #endif /* STM32L471xx */
  513. /* Get the PLLSAI1 Clock configuration -----------------------------------------------*/
  514. PeriphClkInit->PLLSAI1.PLLSAI1N = (uint32_t)((RCC->PLLSAI1CFGR & RCC_PLLSAI1CFGR_PLLSAI1N) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1N));
  515. PeriphClkInit->PLLSAI1.PLLSAI1P = (uint32_t)(((RCC->PLLSAI1CFGR & RCC_PLLSAI1CFGR_PLLSAI1P) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1P)) << 4U) + 7U;
  516. PeriphClkInit->PLLSAI1.PLLSAI1R = (uint32_t)(((RCC->PLLSAI1CFGR & RCC_PLLSAI1CFGR_PLLSAI1R) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1R))+1U) * 2U;
  517. PeriphClkInit->PLLSAI1.PLLSAI1Q = (uint32_t)(((RCC->PLLSAI1CFGR & RCC_PLLSAI1CFGR_PLLSAI1Q) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1Q))+1U) * 2U;
  518. /* Get the PLLSAI2 Clock configuration -----------------------------------------------*/
  519. PeriphClkInit->PLLSAI2.PLLSAI2N = (uint32_t)((RCC->PLLSAI2CFGR & RCC_PLLSAI2CFGR_PLLSAI2N) >> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2N));
  520. PeriphClkInit->PLLSAI2.PLLSAI2P = (uint32_t)(((RCC->PLLSAI2CFGR & RCC_PLLSAI2CFGR_PLLSAI2P) >> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2P)) << 4U) + 7U;
  521. PeriphClkInit->PLLSAI2.PLLSAI2R = (uint32_t)(((RCC->PLLSAI2CFGR & RCC_PLLSAI2CFGR_PLLSAI2R)>> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2R))+1U) * 2U;
  522. /* Get the USART1 clock source ---------------------------------------------*/
  523. PeriphClkInit->Usart1ClockSelection = __HAL_RCC_GET_USART1_SOURCE();
  524. /* Get the USART2 clock source ---------------------------------------------*/
  525. PeriphClkInit->Usart2ClockSelection = __HAL_RCC_GET_USART2_SOURCE();
  526. /* Get the USART3 clock source ---------------------------------------------*/
  527. PeriphClkInit->Usart3ClockSelection = __HAL_RCC_GET_USART3_SOURCE();
  528. /* Get the UART4 clock source ----------------------------------------------*/
  529. PeriphClkInit->Uart4ClockSelection = __HAL_RCC_GET_UART4_SOURCE();
  530. /* Get the UART5 clock source ----------------------------------------------*/
  531. PeriphClkInit->Uart5ClockSelection = __HAL_RCC_GET_UART5_SOURCE();
  532. /* Get the LPUART1 clock source --------------------------------------------*/
  533. PeriphClkInit->Lpuart1ClockSelection = __HAL_RCC_GET_LPUART1_SOURCE();
  534. /* Get the I2C1 clock source -----------------------------------------------*/
  535. PeriphClkInit->I2c1ClockSelection = __HAL_RCC_GET_I2C1_SOURCE();
  536. /* Get the I2C2 clock source ----------------------------------------------*/
  537. PeriphClkInit->I2c2ClockSelection = __HAL_RCC_GET_I2C2_SOURCE();
  538. /* Get the I2C3 clock source -----------------------------------------------*/
  539. PeriphClkInit->I2c3ClockSelection = __HAL_RCC_GET_I2C3_SOURCE();
  540. /* Get the LPTIM1 clock source ---------------------------------------------*/
  541. PeriphClkInit->Lptim1ClockSelection = __HAL_RCC_GET_LPTIM1_SOURCE();
  542. /* Get the LPTIM2 clock source ---------------------------------------------*/
  543. PeriphClkInit->Lptim2ClockSelection = __HAL_RCC_GET_LPTIM2_SOURCE();
  544. /* Get the SAI1 clock source -----------------------------------------------*/
  545. PeriphClkInit->Sai1ClockSelection = __HAL_RCC_GET_SAI1_SOURCE();
  546. /* Get the SAI2 clock source -----------------------------------------------*/
  547. PeriphClkInit->Sai2ClockSelection = __HAL_RCC_GET_SAI2_SOURCE();
  548. /* Get the RTC clock source ------------------------------------------------*/
  549. PeriphClkInit->RTCClockSelection = __HAL_RCC_GET_RTC_SOURCE();
  550. #if defined(USB_OTG_FS)
  551. /* Get the USB clock source ------------------------------------------------*/
  552. PeriphClkInit->UsbClockSelection = __HAL_RCC_GET_USB_SOURCE();
  553. #endif /* USB_OTG_FS */
  554. /* Get the SDMMC1 clock source ---------------------------------------------*/
  555. PeriphClkInit->Sdmmc1ClockSelection = __HAL_RCC_GET_SDMMC1_SOURCE();
  556. /* Get the RNG clock source ------------------------------------------------*/
  557. PeriphClkInit->RngClockSelection = __HAL_RCC_GET_RNG_SOURCE();
  558. /* Get the ADC clock source -----------------------------------------------*/
  559. PeriphClkInit->AdcClockSelection = __HAL_RCC_GET_ADC_SOURCE();
  560. /* Get the SWPMI1 clock source ----------------------------------------------*/
  561. PeriphClkInit->Swpmi1ClockSelection = __HAL_RCC_GET_SWPMI1_SOURCE();
  562. /* Get the DFSDM clock source -------------------------------------------*/
  563. PeriphClkInit->DfsdmClockSelection = __HAL_RCC_GET_DFSDM_SOURCE();
  564. }
  565. /**
  566. * @brief Return the peripheral clock frequency for peripherals with clock source from PLLSAIs
  567. * @note Return 0 if peripheral clock identifier not managed by this API
  568. * @param PeriphClk Peripheral clock identifier
  569. * This parameter can be one of the following values:
  570. * @arg @ref RCC_PERIPHCLK_RTC RTC peripheral clock
  571. * @arg @ref RCC_PERIPHCLK_ADC ADC peripheral clock
  572. * @arg @ref RCC_PERIPHCLK_DFSDM DFSDM peripheral clock
  573. * @arg @ref RCC_PERIPHCLK_I2C1 I2C1 peripheral clock
  574. * @arg @ref RCC_PERIPHCLK_I2C2 I2C2 peripheral clock
  575. * @arg @ref RCC_PERIPHCLK_I2C3 I2C3 peripheral clock
  576. * @arg @ref RCC_PERIPHCLK_LPTIM1 LPTIM1 peripheral clock
  577. * @arg @ref RCC_PERIPHCLK_LPTIM2 LPTIM2 peripheral clock
  578. * @arg @ref RCC_PERIPHCLK_LPUART1 LPUART1 peripheral clock
  579. * @arg @ref RCC_PERIPHCLK_RNG RNG peripheral clock
  580. * @arg @ref RCC_PERIPHCLK_SAI1 SAI1 peripheral clock
  581. * @arg @ref RCC_PERIPHCLK_SAI2 SAI2 peripheral clock
  582. * @arg @ref RCC_PERIPHCLK_SDMMC1 SDMMC1 peripheral clock
  583. * @arg @ref RCC_PERIPHCLK_SWPMI1 SWPMI1 peripheral clock
  584. * @arg @ref RCC_PERIPHCLK_USART1 USART1 peripheral clock
  585. * @arg @ref RCC_PERIPHCLK_USART2 USART1 peripheral clock
  586. * @arg @ref RCC_PERIPHCLK_USART3 USART1 peripheral clock
  587. * @arg @ref RCC_PERIPHCLK_UART4 USART1 peripheral clock
  588. * @arg @ref RCC_PERIPHCLK_UART5 USART1 peripheral clock
  589. * @arg @ref RCC_PERIPHCLK_USB USB peripheral clock (only for devices with USB)
  590. * @retval Frequency in Hz
  591. */
  592. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
  593. {
  594. uint32_t frequency = 0U;
  595. uint32_t srcclk = 0;
  596. uint32_t pllvco = 0, plln = 0, pllp = 0;
  597. /* Check the parameters */
  598. assert_param(IS_RCC_PERIPHCLOCK(PeriphClk));
  599. if(PeriphClk == RCC_PERIPHCLK_RTC)
  600. {
  601. /* Get the current RTC source */
  602. srcclk = __HAL_RCC_GET_RTC_SOURCE();
  603. /* Check if LSE is ready and if RTC clock selection is LSE */
  604. if ((srcclk == RCC_RTCCLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  605. {
  606. frequency = LSE_VALUE;
  607. }
  608. /* Check if LSI is ready and if RTC clock selection is LSI */
  609. else if ((srcclk == RCC_RTCCLKSOURCE_LSI) && (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSIRDY)))
  610. {
  611. frequency = LSI_VALUE;
  612. }
  613. /* Check if HSE is ready and if RTC clock selection is HSI_DIV32*/
  614. else if ((srcclk == RCC_RTCCLKSOURCE_HSE_DIV32) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSERDY)))
  615. {
  616. frequency = HSE_VALUE / 32;
  617. }
  618. /* Clock not enabled for RTC*/
  619. else
  620. {
  621. frequency = 0U;
  622. }
  623. }
  624. else
  625. {
  626. /* Other external peripheral clock source than RTC */
  627. /* Compute PLL clock input */
  628. if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_MSI) /* MSI ? */
  629. {
  630. pllvco = (1U << ((__HAL_RCC_GET_MSI_RANGE() >> 4U) - 4U)) * 1000000U;
  631. }
  632. else if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI) /* HSI ? */
  633. {
  634. pllvco = HSI_VALUE;
  635. }
  636. else if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) /* HSE ? */
  637. {
  638. pllvco = HSE_VALUE;
  639. }
  640. else /* No source */
  641. {
  642. pllvco = 0;
  643. }
  644. /* f(PLL Source) / PLLM */
  645. pllvco = (pllvco / ((READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLM) >> POSITION_VAL(RCC_PLLCFGR_PLLM)) + 1U));
  646. switch(PeriphClk)
  647. {
  648. case RCC_PERIPHCLK_SAI1:
  649. case RCC_PERIPHCLK_SAI2:
  650. if(PeriphClk == RCC_PERIPHCLK_SAI1)
  651. {
  652. srcclk = READ_BIT(RCC->CCIPR, RCC_CCIPR_SAI1SEL);
  653. if(srcclk == RCC_SAI1CLKSOURCE_PIN)
  654. {
  655. frequency = EXTERNAL_SAI1_CLOCK_VALUE;
  656. }
  657. /* Else, PLL clock output to check below */
  658. }
  659. else /* RCC_PERIPHCLK_SAI2 */
  660. {
  661. srcclk = READ_BIT(RCC->CCIPR, RCC_CCIPR_SAI2SEL);
  662. if(srcclk == RCC_SAI2CLKSOURCE_PIN)
  663. {
  664. frequency = EXTERNAL_SAI2_CLOCK_VALUE;
  665. }
  666. /* Else, PLL clock output to check below */
  667. }
  668. if(frequency == 0U)
  669. {
  670. if((srcclk == RCC_SAI1CLKSOURCE_PLL) || (srcclk == RCC_SAI2CLKSOURCE_PLL))
  671. {
  672. if(__HAL_RCC_GET_PLLCLKOUT_CONFIG(RCC_PLL_SAI3CLK) != RESET)
  673. {
  674. /* f(PLLSAI3CLK) = f(VCO input) * PLLN / PLLP */
  675. plln = READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN);
  676. if(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLP) != RESET)
  677. {
  678. pllp = 17U;
  679. }
  680. else
  681. {
  682. pllp = 7U;
  683. }
  684. frequency = (pllvco * plln) / pllp;
  685. }
  686. }
  687. else if(srcclk == 0U) /* RCC_SAI1CLKSOURCE_PLLSAI1 || RCC_SAI2CLKSOURCE_PLLSAI1 */
  688. {
  689. if(__HAL_RCC_GET_PLLSAI1CLKOUT_CONFIG(RCC_PLLSAI1_SAI1CLK) != RESET)
  690. {
  691. /* f(PLLSAI1CLK) = f(VCOSAI1 input) * PLLSAI1N / PLLSAI1P */
  692. plln = READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1N) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1N);
  693. if(READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1P) != RESET)
  694. {
  695. pllp = 17U;
  696. }
  697. else
  698. {
  699. pllp = 7U;
  700. }
  701. frequency = (pllvco * plln) / pllp;
  702. }
  703. }
  704. else if((srcclk == RCC_SAI1CLKSOURCE_PLLSAI2) || (srcclk == RCC_SAI2CLKSOURCE_PLLSAI2))
  705. {
  706. if(__HAL_RCC_GET_PLLSAI2CLKOUT_CONFIG(RCC_PLLSAI2_SAI2CLK) != RESET)
  707. {
  708. /* f(PLLSAI2CLK) = f(VCOSAI2 input) * PLLSAI2N / PLLSAI2P */
  709. plln = READ_BIT(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2N) >> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2N);
  710. if(READ_BIT(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2P) != RESET)
  711. {
  712. pllp = 17U;
  713. }
  714. else
  715. {
  716. pllp = 7U;
  717. }
  718. frequency = (pllvco * plln) / pllp;
  719. }
  720. }
  721. else
  722. {
  723. /* No clock source */
  724. frequency = 0U;
  725. }
  726. }
  727. break;
  728. #if defined(USB_OTG_FS)
  729. case RCC_PERIPHCLK_USB:
  730. #endif /* USB_OTG_FS */
  731. case RCC_PERIPHCLK_RNG:
  732. case RCC_PERIPHCLK_SDMMC1:
  733. srcclk = READ_BIT(RCC->CCIPR, RCC_CCIPR_CLK48SEL);
  734. if(srcclk == RCC_CCIPR_CLK48SEL) /* MSI ? */
  735. {
  736. frequency = (1U << ((__HAL_RCC_GET_MSI_RANGE() >> 4U) - 4U)) * 1000000U;
  737. }
  738. else if(srcclk == RCC_CCIPR_CLK48SEL_1) /* PLL ? */
  739. {
  740. /* f(PLL48M1CLK) = f(VCO input) * PLLN / PLLQ */
  741. plln = READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN);
  742. frequency = (pllvco * plln) / (((READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLQ) >> POSITION_VAL(RCC_PLLCFGR_PLLQ)) + 1U) << 1U);
  743. }
  744. else if(srcclk == RCC_CCIPR_CLK48SEL_0) /* PLLSAI1 ? */
  745. {
  746. /* f(PLL48M2CLK) = f(VCOSAI1 input) * PLLSAI1N / PLLSAI1Q */
  747. plln = READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1N) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1N);
  748. frequency = (pllvco * plln) / (((READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1Q) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1Q)) + 1U) << 1U);
  749. }
  750. else /* No clock source */
  751. {
  752. frequency = 0U;
  753. }
  754. break;
  755. case RCC_PERIPHCLK_USART1:
  756. /* Get the current USART1 source */
  757. srcclk = __HAL_RCC_GET_USART1_SOURCE();
  758. if(srcclk == RCC_USART1CLKSOURCE_PCLK2)
  759. {
  760. frequency = HAL_RCC_GetPCLK2Freq();
  761. }
  762. else if(srcclk == RCC_USART1CLKSOURCE_SYSCLK)
  763. {
  764. frequency = HAL_RCC_GetSysClockFreq();
  765. }
  766. else if((srcclk == RCC_USART1CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  767. {
  768. frequency = HSI_VALUE;
  769. }
  770. else if((srcclk == RCC_USART1CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  771. {
  772. frequency = LSE_VALUE;
  773. }
  774. /* Clock not enabled for USART1 */
  775. else
  776. {
  777. frequency = 0U;
  778. }
  779. break;
  780. case RCC_PERIPHCLK_USART2:
  781. /* Get the current USART2 source */
  782. srcclk = __HAL_RCC_GET_USART2_SOURCE();
  783. if(srcclk == RCC_USART2CLKSOURCE_PCLK1)
  784. {
  785. frequency = HAL_RCC_GetPCLK1Freq();
  786. }
  787. else if(srcclk == RCC_USART2CLKSOURCE_SYSCLK)
  788. {
  789. frequency = HAL_RCC_GetSysClockFreq();
  790. }
  791. else if((srcclk == RCC_USART2CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  792. {
  793. frequency = HSI_VALUE;
  794. }
  795. else if((srcclk == RCC_USART2CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  796. {
  797. frequency = LSE_VALUE;
  798. }
  799. /* Clock not enabled for USART2 */
  800. else
  801. {
  802. frequency = 0U;
  803. }
  804. break;
  805. case RCC_PERIPHCLK_USART3:
  806. /* Get the current USART3 source */
  807. srcclk = __HAL_RCC_GET_USART3_SOURCE();
  808. if(srcclk == RCC_USART3CLKSOURCE_PCLK1)
  809. {
  810. frequency = HAL_RCC_GetPCLK1Freq();
  811. }
  812. else if(srcclk == RCC_USART3CLKSOURCE_SYSCLK)
  813. {
  814. frequency = HAL_RCC_GetSysClockFreq();
  815. }
  816. else if((srcclk == RCC_USART3CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  817. {
  818. frequency = HSI_VALUE;
  819. }
  820. else if((srcclk == RCC_USART3CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  821. {
  822. frequency = LSE_VALUE;
  823. }
  824. /* Clock not enabled for USART3 */
  825. else
  826. {
  827. frequency = 0U;
  828. }
  829. break;
  830. case RCC_PERIPHCLK_UART4:
  831. /* Get the current UART4 source */
  832. srcclk = __HAL_RCC_GET_UART4_SOURCE();
  833. if(srcclk == RCC_UART4CLKSOURCE_PCLK1)
  834. {
  835. frequency = HAL_RCC_GetPCLK1Freq();
  836. }
  837. else if(srcclk == RCC_UART4CLKSOURCE_SYSCLK)
  838. {
  839. frequency = HAL_RCC_GetSysClockFreq();
  840. }
  841. else if((srcclk == RCC_UART4CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  842. {
  843. frequency = HSI_VALUE;
  844. }
  845. else if((srcclk == RCC_UART4CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  846. {
  847. frequency = LSE_VALUE;
  848. }
  849. /* Clock not enabled for UART4 */
  850. else
  851. {
  852. frequency = 0U;
  853. }
  854. break;
  855. case RCC_PERIPHCLK_UART5:
  856. /* Get the current UART5 source */
  857. srcclk = __HAL_RCC_GET_UART5_SOURCE();
  858. if(srcclk == RCC_UART5CLKSOURCE_PCLK1)
  859. {
  860. frequency = HAL_RCC_GetPCLK1Freq();
  861. }
  862. else if(srcclk == RCC_UART5CLKSOURCE_SYSCLK)
  863. {
  864. frequency = HAL_RCC_GetSysClockFreq();
  865. }
  866. else if((srcclk == RCC_UART5CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  867. {
  868. frequency = HSI_VALUE;
  869. }
  870. else if((srcclk == RCC_UART5CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  871. {
  872. frequency = LSE_VALUE;
  873. }
  874. /* Clock not enabled for UART5 */
  875. else
  876. {
  877. frequency = 0U;
  878. }
  879. break;
  880. case RCC_PERIPHCLK_LPUART1:
  881. /* Get the current LPUART1 source */
  882. srcclk = __HAL_RCC_GET_LPUART1_SOURCE();
  883. if(srcclk == RCC_LPUART1CLKSOURCE_PCLK1)
  884. {
  885. frequency = HAL_RCC_GetPCLK1Freq();
  886. }
  887. else if(srcclk == RCC_LPUART1CLKSOURCE_SYSCLK)
  888. {
  889. frequency = HAL_RCC_GetSysClockFreq();
  890. }
  891. else if((srcclk == RCC_LPUART1CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  892. {
  893. frequency = HSI_VALUE;
  894. }
  895. else if((srcclk == RCC_LPUART1CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  896. {
  897. frequency = LSE_VALUE;
  898. }
  899. /* Clock not enabled for LPUART1 */
  900. else
  901. {
  902. frequency = 0U;
  903. }
  904. break;
  905. case RCC_PERIPHCLK_ADC:
  906. srcclk = __HAL_RCC_GET_ADC_SOURCE();
  907. if(srcclk == RCC_ADCCLKSOURCE_SYSCLK)
  908. {
  909. frequency = HAL_RCC_GetSysClockFreq();
  910. }
  911. else if(srcclk == RCC_ADCCLKSOURCE_PLLSAI1)
  912. {
  913. if(__HAL_RCC_GET_PLLSAI1CLKOUT_CONFIG(RCC_PLLSAI1_ADC1CLK) != RESET)
  914. {
  915. /* f(PLLADC1CLK) = f(VCOSAI1 input) * PLLSAI1N / PLLSAI1R */
  916. plln = READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1N) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1N);
  917. frequency = (pllvco * plln) / (((READ_BIT(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1R) >> POSITION_VAL(RCC_PLLSAI1CFGR_PLLSAI1R)) + 1U) << 1U);
  918. }
  919. }
  920. else if(srcclk == RCC_ADCCLKSOURCE_PLLSAI2)
  921. {
  922. if(__HAL_RCC_GET_PLLSAI2CLKOUT_CONFIG(RCC_PLLSAI2_ADC2CLK) != RESET)
  923. {
  924. /* f(PLLADC2CLK) = f(VCOSAI2 input) * PLLSAI2N / PLLSAI2R */
  925. plln = READ_BIT(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2N) >> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2N);
  926. frequency = (pllvco * plln) / (((READ_BIT(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2R) >> POSITION_VAL(RCC_PLLSAI2CFGR_PLLSAI2R)) + 1U) << 1U);
  927. }
  928. }
  929. /* Clock not enabled for ADC */
  930. else
  931. {
  932. frequency = 0U;
  933. }
  934. break;
  935. case RCC_PERIPHCLK_DFSDM:
  936. /* Get the current DFSDM source */
  937. srcclk = __HAL_RCC_GET_DFSDM_SOURCE();
  938. if(srcclk == RCC_DFSDMCLKSOURCE_PCLK)
  939. {
  940. frequency = HAL_RCC_GetPCLK1Freq();
  941. }
  942. else
  943. {
  944. frequency = HAL_RCC_GetSysClockFreq();
  945. }
  946. break;
  947. case RCC_PERIPHCLK_I2C1:
  948. /* Get the current I2C1 source */
  949. srcclk = __HAL_RCC_GET_I2C1_SOURCE();
  950. if(srcclk == RCC_I2C1CLKSOURCE_PCLK1)
  951. {
  952. frequency = HAL_RCC_GetPCLK1Freq();
  953. }
  954. else if(srcclk == RCC_I2C1CLKSOURCE_SYSCLK)
  955. {
  956. frequency = HAL_RCC_GetSysClockFreq();
  957. }
  958. else if((srcclk == RCC_I2C1CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  959. {
  960. frequency = HSI_VALUE;
  961. }
  962. /* Clock not enabled for I2C1 */
  963. else
  964. {
  965. frequency = 0U;
  966. }
  967. break;
  968. case RCC_PERIPHCLK_I2C2:
  969. /* Get the current I2C2 source */
  970. srcclk = __HAL_RCC_GET_I2C2_SOURCE();
  971. if(srcclk == RCC_I2C2CLKSOURCE_PCLK1)
  972. {
  973. frequency = HAL_RCC_GetPCLK1Freq();
  974. }
  975. else if(srcclk == RCC_I2C2CLKSOURCE_SYSCLK)
  976. {
  977. frequency = HAL_RCC_GetSysClockFreq();
  978. }
  979. else if((srcclk == RCC_I2C2CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  980. {
  981. frequency = HSI_VALUE;
  982. }
  983. /* Clock not enabled for I2C2 */
  984. else
  985. {
  986. frequency = 0U;
  987. }
  988. break;
  989. case RCC_PERIPHCLK_I2C3:
  990. /* Get the current I2C3 source */
  991. srcclk = __HAL_RCC_GET_I2C3_SOURCE();
  992. if(srcclk == RCC_I2C3CLKSOURCE_PCLK1)
  993. {
  994. frequency = HAL_RCC_GetPCLK1Freq();
  995. }
  996. else if(srcclk == RCC_I2C3CLKSOURCE_SYSCLK)
  997. {
  998. frequency = HAL_RCC_GetSysClockFreq();
  999. }
  1000. else if((srcclk == RCC_I2C3CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  1001. {
  1002. frequency = HSI_VALUE;
  1003. }
  1004. /* Clock not enabled for I2C3 */
  1005. else
  1006. {
  1007. frequency = 0U;
  1008. }
  1009. break;
  1010. case RCC_PERIPHCLK_LPTIM1:
  1011. /* Get the current LPTIM1 source */
  1012. srcclk = __HAL_RCC_GET_LPTIM1_SOURCE();
  1013. if(srcclk == RCC_LPTIM1CLKSOURCE_PCLK)
  1014. {
  1015. frequency = HAL_RCC_GetPCLK1Freq();
  1016. }
  1017. else if((srcclk == RCC_LPTIM1CLKSOURCE_LSI) && (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSIRDY)))
  1018. {
  1019. frequency = LSI_VALUE;
  1020. }
  1021. else if((srcclk == RCC_LPTIM1CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  1022. {
  1023. frequency = HSI_VALUE;
  1024. }
  1025. else if ((srcclk == RCC_LPTIM1CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  1026. {
  1027. frequency = LSE_VALUE;
  1028. }
  1029. /* Clock not enabled for LPTIM1 */
  1030. else
  1031. {
  1032. frequency = 0U;
  1033. }
  1034. break;
  1035. case RCC_PERIPHCLK_LPTIM2:
  1036. /* Get the current LPTIM2 source */
  1037. srcclk = __HAL_RCC_GET_LPTIM2_SOURCE();
  1038. if(srcclk == RCC_LPTIM2CLKSOURCE_PCLK)
  1039. {
  1040. frequency = HAL_RCC_GetPCLK1Freq();
  1041. }
  1042. else if((srcclk == RCC_LPTIM2CLKSOURCE_LSI) && (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSIRDY)))
  1043. {
  1044. frequency = LSI_VALUE;
  1045. }
  1046. else if((srcclk == RCC_LPTIM2CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  1047. {
  1048. frequency = HSI_VALUE;
  1049. }
  1050. else if ((srcclk == RCC_LPTIM2CLKSOURCE_LSE) && (HAL_IS_BIT_SET(RCC->BDCR, RCC_BDCR_LSERDY)))
  1051. {
  1052. frequency = LSE_VALUE;
  1053. }
  1054. /* Clock not enabled for LPTIM2 */
  1055. else
  1056. {
  1057. frequency = 0U;
  1058. }
  1059. break;
  1060. case RCC_PERIPHCLK_SWPMI1:
  1061. /* Get the current SWPMI1 source */
  1062. srcclk = __HAL_RCC_GET_SWPMI1_SOURCE();
  1063. if(srcclk == RCC_SWPMI1CLKSOURCE_PCLK)
  1064. {
  1065. frequency = HAL_RCC_GetPCLK1Freq();
  1066. }
  1067. else if((srcclk == RCC_SWPMI1CLKSOURCE_HSI) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSIRDY)))
  1068. {
  1069. frequency = HSI_VALUE;
  1070. }
  1071. /* Clock not enabled for SWPMI1 */
  1072. else
  1073. {
  1074. frequency = 0U;
  1075. }
  1076. break;
  1077. default:
  1078. break;
  1079. }
  1080. }
  1081. return(frequency);
  1082. }
  1083. /**
  1084. * @}
  1085. */
  1086. /** @defgroup RCCEx_Exported_Functions_Group2 Extended clock management functions
  1087. * @brief Extended clock management functions
  1088. *
  1089. @verbatim
  1090. ===============================================================================
  1091. ##### Extended clock management functions #####
  1092. ===============================================================================
  1093. [..]
  1094. This subsection provides a set of functions allowing to control the
  1095. activation or deactivation of MSI PLL-mode, PLLSAI1, PLLSAI2, LSE CSS,
  1096. Low speed clock output and clock after wake-up from STOP mode.
  1097. @endverbatim
  1098. * @{
  1099. */
  1100. /**
  1101. * @brief Enable PLLSAI1.
  1102. * @param PLLSAI1Init pointer to an RCC_PLLSAI1InitTypeDef structure that
  1103. * contains the configuration information for the PLLSAI1
  1104. * @retval HAL status
  1105. */
  1106. HAL_StatusTypeDef HAL_RCCEx_EnablePLLSAI1(RCC_PLLSAI1InitTypeDef *PLLSAI1Init)
  1107. {
  1108. uint32_t tickstart = 0U;
  1109. HAL_StatusTypeDef status = HAL_OK;
  1110. /* check for PLLSAI1 Parameters used to output PLLSAI1CLK */
  1111. assert_param(IS_RCC_PLLSAI1N_VALUE(PLLSAI1Init->PLLSAI1N));
  1112. assert_param(IS_RCC_PLLSAI1P_VALUE(PLLSAI1Init->PLLSAI1P));
  1113. assert_param(IS_RCC_PLLSAI1Q_VALUE(PLLSAI1Init->PLLSAI1Q));
  1114. assert_param(IS_RCC_PLLSAI1R_VALUE(PLLSAI1Init->PLLSAI1R));
  1115. assert_param(IS_RCC_PLLSAI1CLOCKOUT_VALUE(PLLSAI1Init->PLLSAI1ClockOut));
  1116. /* Disable the PLLSAI1 */
  1117. __HAL_RCC_PLLSAI1_DISABLE();
  1118. /* Get Start Tick*/
  1119. tickstart = HAL_GetTick();
  1120. /* Wait till PLLSAI1 is ready to be updated */
  1121. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) != RESET)
  1122. {
  1123. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1124. {
  1125. status = HAL_TIMEOUT;
  1126. break;
  1127. }
  1128. }
  1129. if(status == HAL_OK)
  1130. {
  1131. /* Configure the PLLSAI1 Multiplication factor N */
  1132. /* Configure the PLLSAI1 Division factors P, Q and R */
  1133. __HAL_RCC_PLLSAI1_CONFIG(PLLSAI1Init->PLLSAI1N, PLLSAI1Init->PLLSAI1P, PLLSAI1Init->PLLSAI1Q, PLLSAI1Init->PLLSAI1R);
  1134. /* Configure the PLLSAI1 Clock output(s) */
  1135. __HAL_RCC_PLLSAI1CLKOUT_ENABLE(PLLSAI1Init->PLLSAI1ClockOut);
  1136. /* Enable the PLLSAI1 again by setting PLLSAI1ON to 1*/
  1137. __HAL_RCC_PLLSAI1_ENABLE();
  1138. /* Get Start Tick*/
  1139. tickstart = HAL_GetTick();
  1140. /* Wait till PLLSAI1 is ready */
  1141. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) == RESET)
  1142. {
  1143. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1144. {
  1145. status = HAL_TIMEOUT;
  1146. break;
  1147. }
  1148. }
  1149. }
  1150. return status;
  1151. }
  1152. /**
  1153. * @brief Disable PLLSAI1.
  1154. * @retval HAL status
  1155. */
  1156. HAL_StatusTypeDef HAL_RCCEx_DisablePLLSAI1(void)
  1157. {
  1158. uint32_t tickstart = 0U;
  1159. HAL_StatusTypeDef status = HAL_OK;
  1160. /* Disable the PLLSAI1 */
  1161. __HAL_RCC_PLLSAI1_DISABLE();
  1162. /* Get Start Tick*/
  1163. tickstart = HAL_GetTick();
  1164. /* Wait till PLLSAI1 is ready */
  1165. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) != RESET)
  1166. {
  1167. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1168. {
  1169. status = HAL_TIMEOUT;
  1170. break;
  1171. }
  1172. }
  1173. /* Disable the PLLSAI1 Clock outputs */
  1174. __HAL_RCC_PLLSAI1CLKOUT_DISABLE(RCC_PLLSAI1_SAI1CLK|RCC_PLLSAI1_48M2CLK|RCC_PLLSAI1_ADC1CLK);
  1175. return status;
  1176. }
  1177. /**
  1178. * @brief Enable PLLSAI2.
  1179. * @param PLLSAI2Init pointer to an RCC_PLLSAI2InitTypeDef structure that
  1180. * contains the configuration information for the PLLSAI2
  1181. * @retval HAL status
  1182. */
  1183. HAL_StatusTypeDef HAL_RCCEx_EnablePLLSAI2(RCC_PLLSAI2InitTypeDef *PLLSAI2Init)
  1184. {
  1185. uint32_t tickstart = 0U;
  1186. HAL_StatusTypeDef status = HAL_OK;
  1187. /* check for PLLSAI2 Parameters used to output PLLSAI2CLK */
  1188. assert_param(IS_RCC_PLLSAI2N_VALUE(PLLSAI2Init->PLLSAI2N));
  1189. assert_param(IS_RCC_PLLSAI2P_VALUE(PLLSAI2Init->PLLSAI2P));
  1190. assert_param(IS_RCC_PLLSAI2R_VALUE(PLLSAI2Init->PLLSAI2R));
  1191. assert_param(IS_RCC_PLLSAI2CLOCKOUT_VALUE(PLLSAI2Init->PLLSAI2ClockOut));
  1192. /* Disable the PLLSAI2 */
  1193. __HAL_RCC_PLLSAI2_DISABLE();
  1194. /* Get Start Tick*/
  1195. tickstart = HAL_GetTick();
  1196. /* Wait till PLLSAI2 is ready to be updated */
  1197. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) != RESET)
  1198. {
  1199. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1200. {
  1201. status = HAL_TIMEOUT;
  1202. break;
  1203. }
  1204. }
  1205. if(status == HAL_OK)
  1206. {
  1207. /* Configure the PLLSAI2 Multiplication factor N */
  1208. /* Configure the PLLSAI2 Division factors P and R */
  1209. __HAL_RCC_PLLSAI2_CONFIG(PLLSAI2Init->PLLSAI2N, PLLSAI2Init->PLLSAI2P, PLLSAI2Init->PLLSAI2R);
  1210. /* Configure the PLLSAI2 Clock output(s) */
  1211. __HAL_RCC_PLLSAI2CLKOUT_ENABLE(PLLSAI2Init->PLLSAI2ClockOut);
  1212. /* Enable the PLLSAI2 again by setting PLLSAI2ON to 1*/
  1213. __HAL_RCC_PLLSAI2_ENABLE();
  1214. /* Get Start Tick*/
  1215. tickstart = HAL_GetTick();
  1216. /* Wait till PLLSAI2 is ready */
  1217. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) == RESET)
  1218. {
  1219. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1220. {
  1221. status = HAL_TIMEOUT;
  1222. break;
  1223. }
  1224. }
  1225. }
  1226. return status;
  1227. }
  1228. /**
  1229. * @brief Disable PLLISAI2.
  1230. * @retval HAL status
  1231. */
  1232. HAL_StatusTypeDef HAL_RCCEx_DisablePLLSAI2(void)
  1233. {
  1234. uint32_t tickstart = 0U;
  1235. HAL_StatusTypeDef status = HAL_OK;
  1236. /* Disable the PLLSAI2 */
  1237. __HAL_RCC_PLLSAI2_DISABLE();
  1238. /* Get Start Tick*/
  1239. tickstart = HAL_GetTick();
  1240. /* Wait till PLLSAI2 is ready */
  1241. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) != RESET)
  1242. {
  1243. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1244. {
  1245. status = HAL_TIMEOUT;
  1246. break;
  1247. }
  1248. }
  1249. /* Disable the PLLSAI2 Clock outputs */
  1250. __HAL_RCC_PLLSAI2CLKOUT_DISABLE(RCC_PLLSAI2_SAI2CLK|RCC_PLLSAI2_ADC2CLK);
  1251. return status;
  1252. }
  1253. /**
  1254. * @brief Configure the oscillator clock source for wakeup from Stop and CSS backup clock.
  1255. * @param WakeUpClk Wakeup clock
  1256. * This parameter can be one of the following values:
  1257. * @arg @ref RCC_STOP_WAKEUPCLOCK_MSI MSI oscillator selection
  1258. * @arg @ref RCC_STOP_WAKEUPCLOCK_HSI HSI oscillator selection
  1259. * @note This function shall not be called after the Clock Security System on HSE has been
  1260. * enabled.
  1261. * @retval None
  1262. */
  1263. void HAL_RCCEx_WakeUpStopCLKConfig(uint32_t WakeUpClk)
  1264. {
  1265. assert_param(IS_RCC_STOP_WAKEUPCLOCK(WakeUpClk));
  1266. __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(WakeUpClk);
  1267. }
  1268. /**
  1269. * @brief Configure the MSI range after standby mode.
  1270. * @note After Standby its frequency can be selected between 4 possible values (1, 2, 4 or 8 MHz).
  1271. * @param MSIRange MSI range
  1272. * This parameter can be one of the following values:
  1273. * @arg @ref RCC_MSIRANGE_4 Range 4 around 1 MHz
  1274. * @arg @ref RCC_MSIRANGE_5 Range 5 around 2 MHz
  1275. * @arg @ref RCC_MSIRANGE_6 Range 6 around 4 MHz (reset value)
  1276. * @arg @ref RCC_MSIRANGE_7 Range 7 around 8 MHz
  1277. * @retval None
  1278. */
  1279. void HAL_RCCEx_StandbyMSIRangeConfig(uint32_t MSIRange)
  1280. {
  1281. assert_param(IS_RCC_MSI_STANDBY_CLOCK_RANGE(MSIRange));
  1282. __HAL_RCC_MSI_STANDBY_RANGE_CONFIG(MSIRange);
  1283. }
  1284. /**
  1285. * @brief Enable the LSE Clock Security System.
  1286. * @note Prior to enable the LSE Clock Security System, LSE oscillator is to be enabled
  1287. * with HAL_RCC_OscConfig() and the LSE oscillator clock is to be selected as RTC
  1288. * clock with HAL_RCCEx_PeriphCLKConfig().
  1289. * @retval None
  1290. */
  1291. void HAL_RCCEx_EnableLSECSS(void)
  1292. {
  1293. SET_BIT(RCC->BDCR, RCC_BDCR_LSECSSON) ;
  1294. }
  1295. /**
  1296. * @brief Disable the LSE Clock Security System.
  1297. * @note LSE Clock Security System can only be disabled after a LSE failure detection.
  1298. * @retval None
  1299. */
  1300. void HAL_RCCEx_DisableLSECSS(void)
  1301. {
  1302. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSECSSON) ;
  1303. /* Disable LSE CSS IT if any */
  1304. __HAL_RCC_DISABLE_IT(RCC_IT_LSECSS);
  1305. }
  1306. /**
  1307. * @brief Enable the LSE Clock Security System Interrupt & corresponding EXTI line.
  1308. * @note LSE Clock Security System Interrupt is mapped on RTC EXTI line 19
  1309. * @retval None
  1310. */
  1311. void HAL_RCCEx_EnableLSECSS_IT(void)
  1312. {
  1313. /* Enable LSE CSS */
  1314. SET_BIT(RCC->BDCR, RCC_BDCR_LSECSSON) ;
  1315. /* Enable LSE CSS IT */
  1316. __HAL_RCC_ENABLE_IT(RCC_IT_LSECSS);
  1317. /* Enable IT on EXTI Line 19 */
  1318. __HAL_RCC_LSECSS_EXTI_ENABLE_IT();
  1319. __HAL_RCC_LSECSS_EXTI_ENABLE_RISING_EDGE();
  1320. }
  1321. /**
  1322. * @brief Handle the RCC LSE Clock Security System interrupt request.
  1323. * @retval None
  1324. */
  1325. void HAL_RCCEx_LSECSS_IRQHandler(void)
  1326. {
  1327. /* Check RCC LSE CSSF flag */
  1328. if(__HAL_RCC_GET_IT(RCC_IT_LSECSS))
  1329. {
  1330. /* RCC LSE Clock Security System interrupt user callback */
  1331. HAL_RCCEx_LSECSS_Callback();
  1332. /* Clear RCC LSE CSS pending bit */
  1333. __HAL_RCC_CLEAR_IT(RCC_IT_LSECSS);
  1334. }
  1335. }
  1336. /**
  1337. * @brief RCCEx LSE Clock Security System interrupt callback.
  1338. * @retval none
  1339. */
  1340. __weak void HAL_RCCEx_LSECSS_Callback(void)
  1341. {
  1342. /* NOTE : This function should not be modified, when the callback is needed,
  1343. the @ref HAL_RCCEx_LSECSS_Callback should be implemented in the user file
  1344. */
  1345. }
  1346. /**
  1347. * @brief Select the Low Speed clock source to output on LSCO pin (PA2).
  1348. * @param LSCOSource specifies the Low Speed clock source to output.
  1349. * This parameter can be one of the following values:
  1350. * @arg @ref RCC_LSCOSOURCE_LSI LSI clock selected as LSCO source
  1351. * @arg @ref RCC_LSCOSOURCE_LSE LSE clock selected as LSCO source
  1352. * @retval None
  1353. */
  1354. void HAL_RCCEx_EnableLSCO(uint32_t LSCOSource)
  1355. {
  1356. GPIO_InitTypeDef GPIO_InitStruct;
  1357. FlagStatus pwrclkchanged = RESET;
  1358. FlagStatus backupchanged = RESET;
  1359. /* Check the parameters */
  1360. assert_param(IS_RCC_LSCOSOURCE(LSCOSource));
  1361. /* LSCO Pin Clock Enable */
  1362. __LSCO_CLK_ENABLE();
  1363. /* Configue the LSCO pin in analog mode */
  1364. GPIO_InitStruct.Pin = LSCO_PIN;
  1365. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  1366. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  1367. GPIO_InitStruct.Pull = GPIO_NOPULL;
  1368. HAL_GPIO_Init(LSCO_GPIO_PORT, &GPIO_InitStruct);
  1369. /* Update LSCOSEL clock source in Backup Domain control register */
  1370. if(__HAL_RCC_PWR_IS_CLK_DISABLED())
  1371. {
  1372. __HAL_RCC_PWR_CLK_ENABLE();
  1373. pwrclkchanged = SET;
  1374. }
  1375. if(HAL_IS_BIT_CLR(PWR->CR1, PWR_CR1_DBP))
  1376. {
  1377. HAL_PWR_EnableBkUpAccess();
  1378. backupchanged = SET;
  1379. }
  1380. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSCOSEL | RCC_BDCR_LSCOEN, LSCOSource | RCC_BDCR_LSCOEN);
  1381. if(backupchanged == SET)
  1382. {
  1383. HAL_PWR_DisableBkUpAccess();
  1384. }
  1385. if(pwrclkchanged == SET)
  1386. {
  1387. __HAL_RCC_PWR_CLK_DISABLE();
  1388. }
  1389. }
  1390. /**
  1391. * @brief Disable the Low Speed clock output.
  1392. * @retval None
  1393. */
  1394. void HAL_RCCEx_DisableLSCO(void)
  1395. {
  1396. FlagStatus pwrclkchanged = RESET;
  1397. FlagStatus backupchanged = RESET;
  1398. /* Update LSCOEN bit in Backup Domain control register */
  1399. if(__HAL_RCC_PWR_IS_CLK_DISABLED())
  1400. {
  1401. __HAL_RCC_PWR_CLK_ENABLE();
  1402. pwrclkchanged = SET;
  1403. }
  1404. if(HAL_IS_BIT_CLR(PWR->CR1, PWR_CR1_DBP))
  1405. {
  1406. /* Enable access to the backup domain */
  1407. HAL_PWR_EnableBkUpAccess();
  1408. backupchanged = SET;
  1409. }
  1410. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSCOEN);
  1411. /* Restore previous configuration */
  1412. if(backupchanged == SET)
  1413. {
  1414. /* Disable access to the backup domain */
  1415. HAL_PWR_DisableBkUpAccess();
  1416. }
  1417. if(pwrclkchanged == SET)
  1418. {
  1419. __HAL_RCC_PWR_CLK_DISABLE();
  1420. }
  1421. }
  1422. /**
  1423. * @brief Enable the PLL-mode of the MSI.
  1424. * @note Prior to enable the PLL-mode of the MSI for automatic hardware
  1425. * calibration LSE oscillator is to be enabled with HAL_RCC_OscConfig().
  1426. * @retval None
  1427. */
  1428. void HAL_RCCEx_EnableMSIPLLMode(void)
  1429. {
  1430. SET_BIT(RCC->CR, RCC_CR_MSIPLLEN) ;
  1431. }
  1432. /**
  1433. * @brief Disable the PLL-mode of the MSI.
  1434. * @note PLL-mode of the MSI is automatically reset when LSE oscillator is disabled.
  1435. * @retval None
  1436. */
  1437. void HAL_RCCEx_DisableMSIPLLMode(void)
  1438. {
  1439. CLEAR_BIT(RCC->CR, RCC_CR_MSIPLLEN) ;
  1440. }
  1441. /**
  1442. * @}
  1443. */
  1444. /**
  1445. * @}
  1446. */
  1447. /** @addtogroup RCCEx_Private_Functions
  1448. * @{
  1449. */
  1450. /**
  1451. * @brief Configure the parameters N & P of PLLSAI1 and enable PLLSAI1 output clock(s).
  1452. * @param PllSai1 pointer to an RCC_PLLSAI1InitTypeDef structure that
  1453. * contains the configuration parameters N & P as well as PLLSAI1 output clock(s)
  1454. *
  1455. * @note PLLSAI1 is temporary disable to apply new parameters
  1456. *
  1457. * @retval HAL status
  1458. */
  1459. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNP(RCC_PLLSAI1InitTypeDef *PllSai1)
  1460. {
  1461. uint32_t tickstart = 0U;
  1462. HAL_StatusTypeDef status = HAL_OK;
  1463. /* check for PLLSAI1 Parameters used to output PLLSAI1CLK */
  1464. assert_param(IS_RCC_PLLSAI1N_VALUE(PllSai1->PLLSAI1N));
  1465. assert_param(IS_RCC_PLLSAI1P_VALUE(PllSai1->PLLSAI1P));
  1466. assert_param(IS_RCC_PLLSAI1CLOCKOUT_VALUE(PllSai1->PLLSAI1ClockOut));
  1467. /* Disable the PLLSAI1 */
  1468. __HAL_RCC_PLLSAI1_DISABLE();
  1469. /* Get Start Tick*/
  1470. tickstart = HAL_GetTick();
  1471. /* Wait till PLLSAI1 is ready to be updated */
  1472. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) != RESET)
  1473. {
  1474. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1475. {
  1476. status = HAL_TIMEOUT;
  1477. break;
  1478. }
  1479. }
  1480. if(status == HAL_OK)
  1481. {
  1482. /* Configure the PLLSAI1 Multiplication factor N */
  1483. __HAL_RCC_PLLSAI1_MULN_CONFIG(PllSai1->PLLSAI1N);
  1484. /* Configure the PLLSAI1 Division factor P */
  1485. __HAL_RCC_PLLSAI1_DIVP_CONFIG(PllSai1->PLLSAI1P);
  1486. /* Enable the PLLSAI1 again by setting PLLSAI1ON to 1*/
  1487. __HAL_RCC_PLLSAI1_ENABLE();
  1488. /* Get Start Tick*/
  1489. tickstart = HAL_GetTick();
  1490. /* Wait till PLLSAI1 is ready */
  1491. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) == RESET)
  1492. {
  1493. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1494. {
  1495. status = HAL_TIMEOUT;
  1496. break;
  1497. }
  1498. }
  1499. if(status == HAL_OK)
  1500. {
  1501. /* Configure the PLLSAI1 Clock output(s) */
  1502. __HAL_RCC_PLLSAI1CLKOUT_ENABLE(PllSai1->PLLSAI1ClockOut);
  1503. }
  1504. }
  1505. return status;
  1506. }
  1507. /**
  1508. * @brief Configure the parameters N & Q of PLLSAI1 and enable PLLSAI1 output clock(s).
  1509. * @param PllSai1 pointer to an RCC_PLLSAI1InitTypeDef structure that
  1510. * contains the configuration parameters N & Q as well as PLLSAI1 output clock(s)
  1511. *
  1512. * @note PLLSAI1 is temporary disable to apply new parameters
  1513. *
  1514. * @retval HAL status
  1515. */
  1516. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNQ(RCC_PLLSAI1InitTypeDef *PllSai1)
  1517. {
  1518. uint32_t tickstart = 0U;
  1519. HAL_StatusTypeDef status = HAL_OK;
  1520. /* check for PLLSAI1 Parameters used to output PLLSAI1CLK */
  1521. assert_param(IS_RCC_PLLSAI1N_VALUE(PllSai1->PLLSAI1N));
  1522. assert_param(IS_RCC_PLLSAI1Q_VALUE(PllSai1->PLLSAI1Q));
  1523. assert_param(IS_RCC_PLLSAI1CLOCKOUT_VALUE(PllSai1->PLLSAI1ClockOut));
  1524. /* Disable the PLLSAI1 */
  1525. __HAL_RCC_PLLSAI1_DISABLE();
  1526. /* Get Start Tick*/
  1527. tickstart = HAL_GetTick();
  1528. /* Wait till PLLSAI1 is ready to be updated */
  1529. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) != RESET)
  1530. {
  1531. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1532. {
  1533. status = HAL_TIMEOUT;
  1534. break;
  1535. }
  1536. }
  1537. if(status == HAL_OK)
  1538. {
  1539. /* Configure the PLLSAI1 Multiplication factor N */
  1540. __HAL_RCC_PLLSAI1_MULN_CONFIG(PllSai1->PLLSAI1N);
  1541. /* Configure the PLLSAI1 Division factor Q */
  1542. __HAL_RCC_PLLSAI1_DIVQ_CONFIG(PllSai1->PLLSAI1Q);
  1543. /* Enable the PLLSAI1 again by setting PLLSAI1ON to 1*/
  1544. __HAL_RCC_PLLSAI1_ENABLE();
  1545. /* Get Start Tick*/
  1546. tickstart = HAL_GetTick();
  1547. /* Wait till PLLSAI1 is ready */
  1548. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) == RESET)
  1549. {
  1550. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1551. {
  1552. status = HAL_TIMEOUT;
  1553. break;
  1554. }
  1555. }
  1556. if(status == HAL_OK)
  1557. {
  1558. /* Configure the PLLSAI1 Clock output(s) */
  1559. __HAL_RCC_PLLSAI1CLKOUT_ENABLE(PllSai1->PLLSAI1ClockOut);
  1560. }
  1561. }
  1562. return status;
  1563. }
  1564. /**
  1565. * @brief Configure the parameters N & R of PLLSAI1 and enable PLLSAI1 output clock(s).
  1566. * @param PllSai1 pointer to an RCC_PLLSAI1InitTypeDef structure that
  1567. * contains the configuration parameters N & R as well as PLLSAI1 output clock(s)
  1568. *
  1569. * @note PLLSAI1 is temporary disable to apply new parameters
  1570. *
  1571. * @retval HAL status
  1572. */
  1573. static HAL_StatusTypeDef RCCEx_PLLSAI1_ConfigNR(RCC_PLLSAI1InitTypeDef *PllSai1)
  1574. {
  1575. uint32_t tickstart = 0U;
  1576. HAL_StatusTypeDef status = HAL_OK;
  1577. /* check for PLLSAI1 Parameters used to output PLLSAI1CLK */
  1578. assert_param(IS_RCC_PLLSAI1N_VALUE(PllSai1->PLLSAI1N));
  1579. assert_param(IS_RCC_PLLSAI1R_VALUE(PllSai1->PLLSAI1R));
  1580. assert_param(IS_RCC_PLLSAI1CLOCKOUT_VALUE(PllSai1->PLLSAI1ClockOut));
  1581. /* Disable the PLLSAI1 */
  1582. __HAL_RCC_PLLSAI1_DISABLE();
  1583. /* Get Start Tick*/
  1584. tickstart = HAL_GetTick();
  1585. /* Wait till PLLSAI1 is ready to be updated */
  1586. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) != RESET)
  1587. {
  1588. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1589. {
  1590. status = HAL_TIMEOUT;
  1591. break;
  1592. }
  1593. }
  1594. if(status == HAL_OK)
  1595. {
  1596. /* Configure the PLLSAI1 Multiplication factor N */
  1597. __HAL_RCC_PLLSAI1_MULN_CONFIG(PllSai1->PLLSAI1N);
  1598. /* Configure the PLLSAI1 Division factor R */
  1599. __HAL_RCC_PLLSAI1_DIVR_CONFIG(PllSai1->PLLSAI1R);
  1600. /* Enable the PLLSAI1 again by setting PLLSAI1ON to 1*/
  1601. __HAL_RCC_PLLSAI1_ENABLE();
  1602. /* Get Start Tick*/
  1603. tickstart = HAL_GetTick();
  1604. /* Wait till PLLSAI1 is ready */
  1605. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) == RESET)
  1606. {
  1607. if((HAL_GetTick() - tickstart) > PLLSAI1_TIMEOUT_VALUE)
  1608. {
  1609. status = HAL_TIMEOUT;
  1610. break;
  1611. }
  1612. }
  1613. if(status == HAL_OK)
  1614. {
  1615. /* Configure the PLLSAI1 Clock output(s) */
  1616. __HAL_RCC_PLLSAI1CLKOUT_ENABLE(PllSai1->PLLSAI1ClockOut);
  1617. }
  1618. }
  1619. return status;
  1620. }
  1621. /**
  1622. * @brief Configure the parameters N & P of PLLSAI2 and enable PLLSAI2 output clock(s).
  1623. * @param PllSai2 pointer to an RCC_PLLSAI2InitTypeDef structure that
  1624. * contains the configuration parameters N & P as well as PLLSAI2 output clock(s)
  1625. *
  1626. * @note PLLSAI2 is temporary disable to apply new parameters
  1627. *
  1628. * @retval HAL status
  1629. */
  1630. static HAL_StatusTypeDef RCCEx_PLLSAI2_ConfigNP(RCC_PLLSAI2InitTypeDef *PllSai2)
  1631. {
  1632. uint32_t tickstart = 0U;
  1633. HAL_StatusTypeDef status = HAL_OK;
  1634. /* check for PLLSAI2 Parameters */
  1635. assert_param(IS_RCC_PLLSAI2N_VALUE(PllSai2->PLLSAI2N));
  1636. assert_param(IS_RCC_PLLSAI2P_VALUE(PllSai2->PLLSAI2P));
  1637. assert_param(IS_RCC_PLLSAI2CLOCKOUT_VALUE(PllSai2->PLLSAI2ClockOut));
  1638. /* Disable the PLLSAI2 */
  1639. __HAL_RCC_PLLSAI2_DISABLE();
  1640. /* Get Start Tick*/
  1641. tickstart = HAL_GetTick();
  1642. /* Wait till PLLSAI2 is ready */
  1643. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) != RESET)
  1644. {
  1645. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1646. {
  1647. status = HAL_TIMEOUT;
  1648. break;
  1649. }
  1650. }
  1651. if(status == HAL_OK)
  1652. {
  1653. /* Configure the PLLSAI2 Multiplication factor N */
  1654. __HAL_RCC_PLLSAI2_MULN_CONFIG(PllSai2->PLLSAI2N);
  1655. /* Configure the PLLSAI2 Division factor P */
  1656. __HAL_RCC_PLLSAI2_DIVP_CONFIG(PllSai2->PLLSAI2P);
  1657. /* Enable the PLLSAI2 again by setting PLLSAI2ON to 1*/
  1658. __HAL_RCC_PLLSAI2_ENABLE();
  1659. /* Get Start Tick*/
  1660. tickstart = HAL_GetTick();
  1661. /* Wait till PLLSAI2 is ready */
  1662. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) == RESET)
  1663. {
  1664. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1665. {
  1666. status = HAL_TIMEOUT;
  1667. break;
  1668. }
  1669. }
  1670. if(status == HAL_OK)
  1671. {
  1672. /* Configure the PLLSAI2 Clock output(s) */
  1673. __HAL_RCC_PLLSAI2CLKOUT_ENABLE(PllSai2->PLLSAI2ClockOut);
  1674. }
  1675. }
  1676. return status;
  1677. }
  1678. /**
  1679. * @brief Configure the parameters N & R of PLLSAI2 and enable PLLSAI2 output clock(s).
  1680. * @param PllSai2 pointer to an RCC_PLLSAI2InitTypeDef structure that
  1681. * contains the configuration parameters N & R as well as PLLSAI2 output clock(s)
  1682. *
  1683. * @note PLLSAI2 is temporary disable to apply new parameters
  1684. *
  1685. * @retval HAL status
  1686. */
  1687. static HAL_StatusTypeDef RCCEx_PLLSAI2_ConfigNR(RCC_PLLSAI2InitTypeDef *PllSai2)
  1688. {
  1689. uint32_t tickstart = 0U;
  1690. HAL_StatusTypeDef status = HAL_OK;
  1691. /* check for PLLSAI2 Parameters */
  1692. assert_param(IS_RCC_PLLSAI2N_VALUE(PllSai2->PLLSAI2N));
  1693. assert_param(IS_RCC_PLLSAI2R_VALUE(PllSai2->PLLSAI2R));
  1694. assert_param(IS_RCC_PLLSAI2CLOCKOUT_VALUE(PllSai2->PLLSAI2ClockOut));
  1695. /* Disable the PLLSAI2 */
  1696. __HAL_RCC_PLLSAI2_DISABLE();
  1697. /* Get Start Tick*/
  1698. tickstart = HAL_GetTick();
  1699. /* Wait till PLLSAI2 is ready */
  1700. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) != RESET)
  1701. {
  1702. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1703. {
  1704. status = HAL_TIMEOUT;
  1705. break;
  1706. }
  1707. }
  1708. if(status == HAL_OK)
  1709. {
  1710. /* Configure the PLLSAI2 Multiplication factor N */
  1711. __HAL_RCC_PLLSAI2_MULN_CONFIG(PllSai2->PLLSAI2N);
  1712. /* Configure the PLLSAI2 Division factor R */
  1713. __HAL_RCC_PLLSAI2_DIVR_CONFIG(PllSai2->PLLSAI2R);
  1714. /* Enable the PLLSAI2 again by setting PLLSAI2ON to 1*/
  1715. __HAL_RCC_PLLSAI2_ENABLE();
  1716. /* Get Start Tick*/
  1717. tickstart = HAL_GetTick();
  1718. /* Wait till PLLSAI2 is ready */
  1719. while(READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) == RESET)
  1720. {
  1721. if((HAL_GetTick() - tickstart) > PLLSAI2_TIMEOUT_VALUE)
  1722. {
  1723. status = HAL_TIMEOUT;
  1724. break;
  1725. }
  1726. }
  1727. if(status == HAL_OK)
  1728. {
  1729. /* Configure the PLLSAI2 Clock output(s) */
  1730. __HAL_RCC_PLLSAI2CLKOUT_ENABLE(PllSai2->PLLSAI2ClockOut);
  1731. }
  1732. }
  1733. return status;
  1734. }
  1735. /**
  1736. * @}
  1737. */
  1738. /**
  1739. * @}
  1740. */
  1741. #endif /* HAL_RCC_MODULE_ENABLED */
  1742. /**
  1743. * @}
  1744. */
  1745. /**
  1746. * @}
  1747. */
  1748. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/