25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

655 satır
16 KiB

  1. /** @defgroup rcc_file RCC peripheral API
  2. @ingroup peripheral_apis
  3. @brief <b>libopencm3 GD32F1x0 Reset and Clock Control</b>
  4. @version 1.0.0
  5. @author @htmlonly &copy; @endhtmlonly 2009
  6. Federico Ruiz-Ugalde \<memeruiz at gmail dot com\>
  7. @author @htmlonly &copy; @endhtmlonly 2009 Uwe Hermann <uwe@hermann-uwe.de>
  8. @author @htmlonly &copy; @endhtmlonly 2010 Thomas Otto <tommi@viadmin.org>
  9. @date 18 August 2012
  10. This library supports the Reset and Clock Control System in the GD32F1x0
  11. series of ARM Cortex Microcontrollers by GigaDevice.
  12. @note Full support for F170 and F190 devices is not yet provided.
  13. Clock settings and resets for many peripherals are given here rather than in
  14. the corresponding peripheral library.
  15. The library also provides a number of common configurations for the processor
  16. system clock. Not all possible configurations are included.
  17. LGPL License Terms @ref lgpl_license
  18. */
  19. /*
  20. * This file is part of the libopencm3 project.
  21. *
  22. * Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.io>
  23. * Copyright (C) 2009 Federico Ruiz-Ugalde <memeruiz at gmail dot com>
  24. * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
  25. * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
  26. *
  27. * This library is free software: you can redistribute it and/or modify
  28. * it under the terms of the GNU Lesser General Public License as published by
  29. * the Free Software Foundation, either version 3 of the License, or
  30. * (at your option) any later version.
  31. *
  32. * This library is distributed in the hope that it will be useful,
  33. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35. * GNU Lesser General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU Lesser General Public License
  38. * along with this library. If not, see <http://www.gnu.org/licenses/>.
  39. */
  40. /**@{*/
  41. #include <libopencm3/cm3/assert.h>
  42. #include <libopencm3/gd32/rcc.h>
  43. #include <libopencm3/gd32/flash.h>
  44. /** Set the default clock frequencies */
  45. uint32_t rcc_apb1_frequency = 8000000;
  46. uint32_t rcc_apb2_frequency = 8000000;
  47. uint32_t rcc_ahb_frequency = 8000000;
  48. const struct rcc_clock_scale rcc_hsi_configs[] = {
  49. { /* 48MHz */
  50. .pllmul = RCC_CFGR_PLLMUL_PLL_CLK_MUL12,
  51. .hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
  52. .ppre1 = RCC_CFGR_PPRE1_HCLK_DIV2,
  53. .ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
  54. .adcpre = RCC_CFGR_ADCPRE_PCLK2_DIV8,
  55. .use_hse = false,
  56. .ahb_frequency = 48000000,
  57. .apb1_frequency = 24000000,
  58. .apb2_frequency = 48000000,
  59. },
  60. { /* 64MHz */
  61. .pllmul = RCC_CFGR_PLLMUL_PLL_CLK_MUL16,
  62. .hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
  63. .ppre1 = RCC_CFGR_PPRE1_HCLK_DIV2,
  64. .ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
  65. .adcpre = RCC_CFGR_ADCPRE_PCLK2_DIV8,
  66. .use_hse = false,
  67. .ahb_frequency = 64000000,
  68. .apb1_frequency = 32000000,
  69. .apb2_frequency = 64000000,
  70. }
  71. };
  72. const struct rcc_clock_scale rcc_hse8_configs[] = {
  73. { /* 72MHz */
  74. .pllmul = RCC_CFGR_PLLMUL_PLL_CLK_MUL9,
  75. .hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
  76. .ppre1 = RCC_CFGR_PPRE1_HCLK_DIV2,
  77. .ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
  78. .adcpre = RCC_CFGR_ADCPRE_PCLK2_DIV8,
  79. .usbpre = RCC_CFGR_USBPRE_PLL_CLK_DIV1_5,
  80. .use_hse = true,
  81. .pll_hse_prediv = RCC_CFGR2_PREDIV_NODIV,
  82. .ahb_frequency = 72000000,
  83. .apb1_frequency = 36000000,
  84. .apb2_frequency = 72000000,
  85. },
  86. };
  87. /*---------------------------------------------------------------------------*/
  88. /** @brief RCC Clear the Oscillator Ready Interrupt Flag
  89. Clear the interrupt flag that was set when a clock oscillator became ready to
  90. use.
  91. @param[in] osc Oscillator ID
  92. */
  93. void rcc_osc_ready_int_clear(enum rcc_osc osc)
  94. {
  95. switch (osc) {
  96. case RCC_PLL:
  97. RCC_CIR |= RCC_CIR_PLLRDYC;
  98. break;
  99. case RCC_HSE:
  100. RCC_CIR |= RCC_CIR_HSERDYC;
  101. break;
  102. case RCC_HSI:
  103. RCC_CIR |= RCC_CIR_HSIRDYC;
  104. break;
  105. case RCC_LSE:
  106. RCC_CIR |= RCC_CIR_LSERDYC;
  107. break;
  108. case RCC_LSI:
  109. RCC_CIR |= RCC_CIR_LSIRDYC;
  110. break;
  111. }
  112. }
  113. /*---------------------------------------------------------------------------*/
  114. /** @brief RCC Enable the Oscillator Ready Interrupt
  115. @param[in] osc Oscillator ID
  116. */
  117. void rcc_osc_ready_int_enable(enum rcc_osc osc)
  118. {
  119. switch (osc) {
  120. case RCC_PLL:
  121. RCC_CIR |= RCC_CIR_PLLRDYIE;
  122. break;
  123. case RCC_HSE:
  124. RCC_CIR |= RCC_CIR_HSERDYIE;
  125. break;
  126. case RCC_HSI:
  127. RCC_CIR |= RCC_CIR_HSIRDYIE;
  128. break;
  129. case RCC_LSE:
  130. RCC_CIR |= RCC_CIR_LSERDYIE;
  131. break;
  132. case RCC_LSI:
  133. RCC_CIR |= RCC_CIR_LSIRDYIE;
  134. break;
  135. }
  136. }
  137. /*---------------------------------------------------------------------------*/
  138. /** @brief RCC Disable the Oscillator Ready Interrupt
  139. @param[in] osc Oscillator ID
  140. */
  141. void rcc_osc_ready_int_disable(enum rcc_osc osc)
  142. {
  143. switch (osc) {
  144. case RCC_PLL:
  145. RCC_CIR &= ~RCC_CIR_PLLRDYIE;
  146. break;
  147. case RCC_HSE:
  148. RCC_CIR &= ~RCC_CIR_HSERDYIE;
  149. break;
  150. case RCC_HSI:
  151. RCC_CIR &= ~RCC_CIR_HSIRDYIE;
  152. break;
  153. case RCC_LSE:
  154. RCC_CIR &= ~RCC_CIR_LSERDYIE;
  155. break;
  156. case RCC_LSI:
  157. RCC_CIR &= ~RCC_CIR_LSIRDYIE;
  158. break;
  159. }
  160. }
  161. /*---------------------------------------------------------------------------*/
  162. /** @brief RCC Read the Oscillator Ready Interrupt Flag
  163. @param[in] osc Oscillator ID
  164. @returns int. Boolean value for flag set.
  165. */
  166. int rcc_osc_ready_int_flag(enum rcc_osc osc)
  167. {
  168. switch (osc) {
  169. case RCC_PLL:
  170. return ((RCC_CIR & RCC_CIR_PLLRDYF) != 0);
  171. break;
  172. case RCC_HSE:
  173. return ((RCC_CIR & RCC_CIR_HSERDYF) != 0);
  174. break;
  175. case RCC_HSI:
  176. return ((RCC_CIR & RCC_CIR_HSIRDYF) != 0);
  177. break;
  178. case RCC_LSE:
  179. return ((RCC_CIR & RCC_CIR_LSERDYF) != 0);
  180. break;
  181. case RCC_LSI:
  182. return ((RCC_CIR & RCC_CIR_LSIRDYF) != 0);
  183. break;
  184. }
  185. cm3_assert_not_reached();
  186. }
  187. /*---------------------------------------------------------------------------*/
  188. /** @brief RCC Clear the Clock Security System Interrupt Flag
  189. */
  190. void rcc_css_int_clear(void)
  191. {
  192. RCC_CIR |= RCC_CIR_CSSC;
  193. }
  194. /*---------------------------------------------------------------------------*/
  195. /** @brief RCC Read the Clock Security System Interrupt Flag
  196. @returns int. Boolean value for flag set.
  197. */
  198. int rcc_css_int_flag(void)
  199. {
  200. return ((RCC_CIR & RCC_CIR_CSSF) != 0);
  201. }
  202. /*---------------------------------------------------------------------------*/
  203. /** @brief RCC Wait for Oscillator Ready.
  204. @param[in] osc Oscillator ID
  205. */
  206. void rcc_wait_for_osc_ready(enum rcc_osc osc)
  207. {
  208. switch (osc) {
  209. case RCC_PLL:
  210. while ((RCC_CR & RCC_CR_PLLRDY) == 0);
  211. break;
  212. case RCC_HSE:
  213. while ((RCC_CR & RCC_CR_HSERDY) == 0);
  214. break;
  215. case RCC_HSI:
  216. while ((RCC_CR & RCC_CR_HSIRDY) == 0);
  217. break;
  218. case RCC_LSE:
  219. while ((RCC_BDCR & RCC_BDCR_LSERDY) == 0);
  220. break;
  221. case RCC_LSI:
  222. while ((RCC_CSR & RCC_CSR_LSIRDY) == 0);
  223. break;
  224. }
  225. }
  226. /*---------------------------------------------------------------------------*/
  227. /** @brief RCC Turn on an Oscillator.
  228. Enable an oscillator and power on. Each oscillator requires an amount of time
  229. to settle to a usable state. Refer to datasheets for time delay information. A
  230. status flag is available to indicate when the oscillator becomes ready (see
  231. @ref rcc_osc_ready_int_flag and @ref rcc_wait_for_osc_ready).
  232. @note The LSE clock is in the backup domain and cannot be enabled until the
  233. backup domain write protection has been removed (see @ref
  234. pwr_disable_backup_domain_write_protect).
  235. @param[in] osc Oscillator ID
  236. */
  237. void rcc_osc_on(enum rcc_osc osc)
  238. {
  239. switch (osc) {
  240. case RCC_PLL:
  241. RCC_CR |= RCC_CR_PLLON;
  242. break;
  243. case RCC_HSE:
  244. RCC_CR |= RCC_CR_HSEON;
  245. break;
  246. case RCC_HSI:
  247. RCC_CR |= RCC_CR_HSION;
  248. break;
  249. case RCC_LSE:
  250. RCC_BDCR |= RCC_BDCR_LSEON;
  251. break;
  252. case RCC_LSI:
  253. RCC_CSR |= RCC_CSR_LSION;
  254. break;
  255. }
  256. }
  257. /*---------------------------------------------------------------------------*/
  258. /** @brief RCC Turn off an Oscillator.
  259. Disable an oscillator and power off.
  260. @note An oscillator cannot be turned off if it is selected as the system clock.
  261. @note The LSE clock is in the backup domain and cannot be disabled until the
  262. backup domain write protection has been removed (see
  263. @ref pwr_disable_backup_domain_write_protect) or the backup domain has been
  264. (see reset @ref rcc_backupdomain_reset).
  265. @param[in] osc Oscillator ID
  266. */
  267. void rcc_osc_off(enum rcc_osc osc)
  268. {
  269. switch (osc) {
  270. case RCC_PLL:
  271. RCC_CR &= ~RCC_CR_PLLON;
  272. break;
  273. case RCC_HSE:
  274. RCC_CR &= ~RCC_CR_HSEON;
  275. break;
  276. case RCC_HSI:
  277. RCC_CR &= ~RCC_CR_HSION;
  278. break;
  279. case RCC_LSE:
  280. RCC_BDCR &= ~RCC_BDCR_LSEON;
  281. break;
  282. case RCC_LSI:
  283. RCC_CSR &= ~RCC_CSR_LSION;
  284. break;
  285. }
  286. }
  287. /*---------------------------------------------------------------------------*/
  288. /** @brief RCC Enable the Clock Security System.
  289. */
  290. void rcc_css_enable(void)
  291. {
  292. RCC_CR |= RCC_CR_CSSON;
  293. }
  294. /*---------------------------------------------------------------------------*/
  295. /** @brief RCC Disable the Clock Security System.
  296. */
  297. void rcc_css_disable(void)
  298. {
  299. RCC_CR &= ~RCC_CR_CSSON;
  300. }
  301. /*---------------------------------------------------------------------------*/
  302. /** @brief RCC Set the Source for the System Clock.
  303. @param[in] clk System Clock Selection @ref rcc_cfgr_scs
  304. */
  305. void rcc_set_sysclk_source(uint32_t clk)
  306. {
  307. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_SW) |
  308. (clk << RCC_CFGR_SW_SHIFT);
  309. }
  310. /*---------------------------------------------------------------------------*/
  311. /** @brief RCC Set the PLL Multiplication Factor.
  312. @note This only has effect when the PLL is disabled.
  313. @param[in] mul PLL multiplication factor @ref rcc_cfgr_pmf
  314. */
  315. void rcc_set_pll_multiplication_factor(uint32_t mul)
  316. {
  317. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PLLMUL_0_3 & ~RCC_CFGR_PLLMUL_4) |
  318. ((mul & 0xf) << RCC_CFGR_PLLMUL_0_3_SHIFT) |
  319. ((!!(mul & 0x10)) << RCC_CFGR_PLLMUL_4_SHIFT);
  320. }
  321. /*---------------------------------------------------------------------------*/
  322. /** @brief RCC Set the PLL Clock Source.
  323. @note This only has effect when the PLL is disabled.
  324. @param[in] pllsrc PLL clock source @ref rcc_cfgr_pcs
  325. */
  326. void rcc_set_pll_source(uint32_t pllsrc)
  327. {
  328. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PLLSRC) |
  329. (pllsrc << 16);
  330. }
  331. /*---------------------------------------------------------------------------*/
  332. /** @brief RCC Set the HSE Frequency Divider used as PLL Clock Source.
  333. @note This only has effect when the PLL is disabled.
  334. @param[in] pllxtpre HSE division factor @ref rcc_cfgr_hsepre
  335. */
  336. void rcc_set_pllxtpre(uint32_t pllxtpre)
  337. {
  338. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PLLXTPRE) |
  339. (pllxtpre << 17);
  340. }
  341. /*---------------------------------------------------------------------------*/
  342. /** @brief RCC RTC Clock Enabled Flag
  343. @returns uint32_t. Nonzero if the RTC Clock is enabled.
  344. */
  345. uint32_t rcc_rtc_clock_enabled_flag(void)
  346. {
  347. return RCC_BDCR & RCC_BDCR_RTCEN;
  348. }
  349. /*---------------------------------------------------------------------------*/
  350. /** @brief RCC Enable the RTC clock
  351. */
  352. void rcc_enable_rtc_clock(void)
  353. {
  354. RCC_BDCR |= RCC_BDCR_RTCEN;
  355. }
  356. /*---------------------------------------------------------------------------*/
  357. /** @brief RCC Set the Source for the RTC clock
  358. @param[in] clock_source RTC clock source. Only HSE/128, LSE and LSI.
  359. */
  360. void rcc_set_rtc_clock_source(enum rcc_osc clock_source)
  361. {
  362. uint32_t reg32;
  363. switch (clock_source) {
  364. case RCC_LSE:
  365. /* Turn the LSE on and wait while it stabilises. */
  366. RCC_BDCR |= RCC_BDCR_LSEON;
  367. while ((reg32 = (RCC_BDCR & RCC_BDCR_LSERDY)) == 0);
  368. /* Choose LSE as the RTC clock source. */
  369. RCC_BDCR &= ~((1 << 8) | (1 << 9));
  370. RCC_BDCR |= (1 << 8);
  371. break;
  372. case RCC_LSI:
  373. /* Turn the LSI on and wait while it stabilises. */
  374. RCC_CSR |= RCC_CSR_LSION;
  375. while ((reg32 = (RCC_CSR & RCC_CSR_LSIRDY)) == 0);
  376. /* Choose LSI as the RTC clock source. */
  377. RCC_BDCR &= ~((1 << 8) | (1 << 9));
  378. RCC_BDCR |= (1 << 9);
  379. break;
  380. case RCC_HSE:
  381. /* Turn the HSE on and wait while it stabilises. */
  382. RCC_CR |= RCC_CR_HSEON;
  383. while ((reg32 = (RCC_CR & RCC_CR_HSERDY)) == 0);
  384. /* Choose HSE as the RTC clock source. */
  385. RCC_BDCR &= ~((1 << 8) | (1 << 9));
  386. RCC_BDCR |= (1 << 9) | (1 << 8);
  387. break;
  388. case RCC_PLL:
  389. case RCC_HSI:
  390. /* Unusable clock source, here to prevent warnings. */
  391. /* Turn off clock sources to RTC. */
  392. RCC_BDCR &= ~((1 << 8) | (1 << 9));
  393. break;
  394. }
  395. }
  396. /*---------------------------------------------------------------------------*/
  397. /** @brief ADC Setup the A/D Clock
  398. The ADC's have a common clock prescale setting.
  399. @param[in] adcpre Prescale divider taken from @ref rcc_cfgr_adcpre
  400. */
  401. void rcc_set_adcpre(uint32_t adcpre)
  402. {
  403. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_ADCPRE) |
  404. (adcpre << RCC_CFGR_ADCPRE_SHIFT);
  405. }
  406. /*---------------------------------------------------------------------------*/
  407. /** @brief RCC Set the APB2 Prescale Factor.
  408. @param[in] ppre2 APB2 prescale factor @ref rcc_cfgr_apb2pre
  409. */
  410. void rcc_set_ppre2(uint32_t ppre2)
  411. {
  412. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PPRE2) |
  413. (ppre2 << RCC_CFGR_PPRE2_SHIFT);
  414. }
  415. /*---------------------------------------------------------------------------*/
  416. /** @brief RCC Set the APB1 Prescale Factor.
  417. @note The APB1 clock frequency must not exceed 36MHz.
  418. @param[in] ppre1 APB1 prescale factor @ref rcc_cfgr_apb1pre
  419. */
  420. void rcc_set_ppre1(uint32_t ppre1)
  421. {
  422. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PPRE1) |
  423. (ppre1 << RCC_CFGR_PPRE1_SHIFT);
  424. }
  425. /*---------------------------------------------------------------------------*/
  426. /** @brief RCC Set the AHB Prescale Factor.
  427. @param[in] hpre AHB prescale factor @ref rcc_cfgr_ahbpre
  428. */
  429. void rcc_set_hpre(uint32_t hpre)
  430. {
  431. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_HPRE) |
  432. (hpre << RCC_CFGR_HPRE_SHIFT);
  433. }
  434. /*---------------------------------------------------------------------------*/
  435. /** @brief RCC Set the USB Prescale Factor.
  436. The prescale factor can be set to 1 (no prescale) for use when the PLL clock is
  437. 48MHz, or 1.5 to generate the 48MHz USB clock from a 64MHz PLL clock.
  438. @note This bit cannot be reset while the USB clock is enabled.
  439. @param[in] usbpre USB prescale factor @ref rcc_cfgr_usbpre
  440. */
  441. void rcc_set_usbpre(uint32_t usbpre)
  442. {
  443. RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_USBPRE) | usbpre;
  444. }
  445. void rcc_set_prediv(uint32_t prediv)
  446. {
  447. RCC_CFGR2 = (RCC_CFGR2 & ~RCC_CFGR2_PREDIV) | prediv;
  448. }
  449. /*---------------------------------------------------------------------------*/
  450. /** @brief RCC Get the System Clock Source.
  451. @returns Unsigned int32. System clock source:
  452. @li 00 indicates HSE
  453. @li 01 indicates LSE
  454. @li 02 indicates PLL
  455. */
  456. uint32_t rcc_system_clock_source(void)
  457. {
  458. /* Return the clock source which is used as system clock. */
  459. return (RCC_CFGR & RCC_CFGR_SWS) >> RCC_CFGR_SWS_SHIFT;
  460. }
  461. /*---------------------------------------------------------------------------*/
  462. /*
  463. * These functions are setting up the whole clock system for the most common
  464. * input clock and output clock configurations.
  465. */
  466. /*---------------------------------------------------------------------------*/
  467. /**
  468. * Setup clocks to run from PLL.
  469. * The arguments provide the pll source, multipliers, dividers, all that's
  470. * needed to establish a system clock.
  471. * @param clock clock information structure
  472. */
  473. void rcc_clock_setup_pll(const struct rcc_clock_scale *clock)
  474. {
  475. if (clock->use_hse) {
  476. /* Enable external high-speed oscillator. */
  477. rcc_osc_on(RCC_HSE);
  478. rcc_wait_for_osc_ready(RCC_HSE);
  479. rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSECLK);
  480. } else {
  481. /* Enable internal high-speed oscillator. */
  482. rcc_osc_on(RCC_HSI);
  483. rcc_wait_for_osc_ready(RCC_HSI);
  484. rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSICLK);
  485. }
  486. /*
  487. * Set prescalers for AHB, ADC, APB1, APB2 and USB.
  488. * Do this before touching the PLL (TODO: why?).
  489. */
  490. rcc_set_hpre(clock->hpre);
  491. rcc_set_ppre1(clock->ppre1);
  492. rcc_set_ppre2(clock->ppre2);
  493. rcc_set_adcpre(clock->adcpre);
  494. if (clock->use_hse)
  495. rcc_set_usbpre(clock->usbpre);
  496. /* Set the PLL multiplication factor. */
  497. rcc_set_pll_multiplication_factor(clock->pllmul);
  498. if (clock->use_hse) {
  499. /* Select HSE as PLL source. */
  500. rcc_set_pll_source(RCC_CFGR_PLLSRC_HSE_CLK);
  501. /*
  502. * External frequency undivided before entering PLL
  503. * (only valid/needed for HSE).
  504. */
  505. rcc_set_prediv(clock->pll_hse_prediv);
  506. } else {
  507. /* Select HSI/2 as PLL source. */
  508. rcc_set_pll_source(RCC_CFGR_PLLSRC_HSI_CLK_DIV2);
  509. }
  510. /* Enable PLL oscillator and wait for it to stabilize. */
  511. rcc_osc_on(RCC_PLL);
  512. rcc_wait_for_osc_ready(RCC_PLL);
  513. /* Select PLL as SYSCLK source. */
  514. rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_PLLCLK);
  515. /* Set the peripheral clock frequencies used */
  516. rcc_ahb_frequency = clock->ahb_frequency;
  517. rcc_apb1_frequency = clock->apb1_frequency;
  518. rcc_apb2_frequency = clock->apb2_frequency;
  519. }
  520. /*---------------------------------------------------------------------------*/
  521. /** @brief RCC Reset the Backup Domain
  522. The backup domain registers are reset to disable RTC controls and clear user
  523. data.
  524. */
  525. void rcc_backupdomain_reset(void)
  526. {
  527. /* Set the backup domain software reset. */
  528. RCC_BDCR |= RCC_BDCR_BDRST;
  529. /* Clear the backup domain software reset. */
  530. RCC_BDCR &= ~RCC_BDCR_BDRST;
  531. }
  532. /**@}*/