stm32_rcc.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file STM32F3xx/stm32_rcc.h
  15. * @brief RCC helper driver header.
  16. * @note This file requires definitions from the ST header file
  17. * @p stm32f30x.h.
  18. *
  19. * @addtogroup STM32F3xx_RCC
  20. * @{
  21. */
  22. #ifndef STM32_RCC_H
  23. #define STM32_RCC_H
  24. /*===========================================================================*/
  25. /* Driver constants. */
  26. /*===========================================================================*/
  27. /*===========================================================================*/
  28. /* Driver pre-compile time settings. */
  29. /*===========================================================================*/
  30. /*===========================================================================*/
  31. /* Derived constants and error checks. */
  32. /*===========================================================================*/
  33. /*===========================================================================*/
  34. /* Driver data structures and types. */
  35. /*===========================================================================*/
  36. /*===========================================================================*/
  37. /* Driver macros. */
  38. /*===========================================================================*/
  39. /**
  40. * @name Generic RCC operations
  41. * @{
  42. */
  43. /**
  44. * @brief Enables the clock of one or more peripheral on the APB1 bus.
  45. *
  46. * @param[in] mask APB1 peripherals mask
  47. * @param[in] lp low power enable flag
  48. *
  49. * @api
  50. */
  51. #define rccEnableAPB1(mask, lp) { \
  52. RCC->APB1ENR |= (mask); \
  53. (void)RCC->APB1ENR; \
  54. }
  55. /**
  56. * @brief Disables the clock of one or more peripheral on the APB1 bus.
  57. *
  58. * @param[in] mask APB1 peripherals mask
  59. *
  60. * @api
  61. */
  62. #define rccDisableAPB1(mask) { \
  63. RCC->APB1ENR &= ~(mask); \
  64. (void)RCC->APB1ENR; \
  65. }
  66. /**
  67. * @brief Resets one or more peripheral on the APB1 bus.
  68. *
  69. * @param[in] mask APB1 peripherals mask
  70. *
  71. * @api
  72. */
  73. #define rccResetAPB1(mask) { \
  74. RCC->APB1RSTR |= (mask); \
  75. RCC->APB1RSTR &= ~(mask); \
  76. (void)RCC->APB1RSTR; \
  77. }
  78. /**
  79. * @brief Enables the clock of one or more peripheral on the APB2 bus.
  80. *
  81. * @param[in] mask APB2 peripherals mask
  82. * @param[in] lp low power enable flag
  83. *
  84. * @api
  85. */
  86. #define rccEnableAPB2(mask, lp) { \
  87. RCC->APB2ENR |= (mask); \
  88. (void)RCC->APB2ENR; \
  89. }
  90. /**
  91. * @brief Disables the clock of one or more peripheral on the APB2 bus.
  92. *
  93. * @param[in] mask APB2 peripherals mask
  94. *
  95. * @api
  96. */
  97. #define rccDisableAPB2(mask) { \
  98. RCC->APB2ENR &= ~(mask); \
  99. (void)RCC->APB2ENR; \
  100. }
  101. /**
  102. * @brief Resets one or more peripheral on the APB2 bus.
  103. *
  104. * @param[in] mask APB2 peripherals mask
  105. *
  106. * @api
  107. */
  108. #define rccResetAPB2(mask) { \
  109. RCC->APB2RSTR |= (mask); \
  110. RCC->APB2RSTR &= ~(mask); \
  111. (void)RCC->APB2RSTR; \
  112. }
  113. /**
  114. * @brief Enables the clock of one or more peripheral on the AHB bus.
  115. *
  116. * @param[in] mask AHB peripherals mask
  117. * @param[in] lp low power enable flag
  118. *
  119. * @api
  120. */
  121. #define rccEnableAHB(mask, lp) { \
  122. RCC->AHBENR |= (mask); \
  123. (void)RCC->AHBENR; \
  124. }
  125. /**
  126. * @brief Disables the clock of one or more peripheral on the AHB bus.
  127. *
  128. * @param[in] mask AHB peripherals mask
  129. *
  130. * @api
  131. */
  132. #define rccDisableAHB(mask) { \
  133. RCC->AHBENR &= ~(mask); \
  134. (void)RCC->AHBENR; \
  135. }
  136. /**
  137. * @brief Resets one or more peripheral on the AHB bus.
  138. *
  139. * @param[in] mask AHB peripherals mask
  140. *
  141. * @api
  142. */
  143. #define rccResetAHB(mask) { \
  144. RCC->AHBRSTR |= (mask); \
  145. RCC->AHBRSTR &= ~(mask); \
  146. (void)RCC->AHBRSTR; \
  147. }
  148. /** @} */
  149. /**
  150. * @name ADC peripherals specific RCC operations
  151. * @{
  152. */
  153. /**
  154. * @brief Enables the ADC1/ADC2 peripheral clock.
  155. *
  156. * @param[in] lp low power enable flag
  157. *
  158. * @api
  159. */
  160. #if defined(RCC_AHBENR_ADC12EN) || defined(__DOXYGEN__)
  161. #define rccEnableADC12(lp) rccEnableAHB(RCC_AHBENR_ADC12EN, lp)
  162. #else
  163. #define rccEnableADC12(lp) rccEnableAHB(RCC_AHBENR_ADC1EN, lp)
  164. #endif
  165. /**
  166. * @brief Disables the ADC1/ADC2 peripheral clock.
  167. *
  168. * @api
  169. */
  170. #if defined(RCC_AHBENR_ADC12EN) || defined(__DOXYGEN__)
  171. #define rccDisableADC12() rccDisableAHB(RCC_AHBENR_ADC12EN)
  172. #else
  173. #define rccDisableADC12() rccDisableAHB(RCC_AHBENR_ADC1EN)
  174. #endif
  175. /**
  176. * @brief Resets the ADC1/ADC2 peripheral.
  177. *
  178. * @api
  179. */
  180. #if defined(RCC_AHBRSTR_ADC12RST) || defined(__DOXYGEN__)
  181. #define rccResetADC12() rccResetAHB(RCC_AHBRSTR_ADC12RST)
  182. #else
  183. #define rccResetADC12() rccResetAHB(RCC_AHBRSTR_ADC1RST)
  184. #endif
  185. /**
  186. * @brief Enables the ADC3/ADC4 peripheral clock.
  187. *
  188. * @param[in] lp low power enable flag
  189. *
  190. * @api
  191. */
  192. #if defined(RCC_AHBENR_ADC34EN) || defined(__DOXYGEN__)
  193. #define rccEnableADC34(lp) rccEnableAHB(RCC_AHBENR_ADC34EN, lp)
  194. #else
  195. #define rccEnableADC34(lp) rccEnableAHB(RCC_AHBENR_ADC3EN, lp)
  196. #endif
  197. /**
  198. * @brief Disables the ADC3/ADC4 peripheral clock.
  199. *
  200. * @api
  201. */
  202. #if defined(RCC_AHBENR_ADC34EN) || defined(__DOXYGEN__)
  203. #define rccDisableADC34() rccDisableAHB(RCC_AHBENR_ADC34EN)
  204. #else
  205. #define rccDisableADC34() rccDisableAHB(RCC_AHBENR_ADC3EN)
  206. #endif
  207. /**
  208. * @brief Resets the ADC3/ADC4 peripheral.
  209. *
  210. * @api
  211. */
  212. #if defined(RCC_AHBRSTR_ADC34RST) || defined(__DOXYGEN__)
  213. #define rccResetADC34() rccResetAHB(RCC_AHBRSTR_ADC34RST)
  214. #else
  215. #define rccResetADC34() rccResetAHB(RCC_AHBRSTR_ADC3RST)
  216. #endif
  217. /** @} */
  218. /**
  219. * @name DAC peripheral specific RCC operations
  220. * @{
  221. */
  222. /**
  223. * @brief Enables the DAC1 peripheral clock.
  224. *
  225. * @param[in] lp low power enable flag
  226. *
  227. * @api
  228. */
  229. #define rccEnableDAC1(lp) rccEnableAPB1(RCC_APB1ENR_DAC1EN, lp)
  230. /**
  231. * @brief Disables the DAC1 peripheral clock.
  232. *
  233. * @api
  234. */
  235. #define rccDisableDAC1() rccDisableAPB1(RCC_APB1ENR_DAC1EN)
  236. /**
  237. * @brief Resets the DAC1 peripheral.
  238. *
  239. * @api
  240. */
  241. #define rccResetDAC1() rccResetAPB1(RCC_APB1RSTR_DAC1RST)
  242. /**
  243. * @brief Enables the DAC1 peripheral clock.
  244. *
  245. * @param[in] lp low power enable flag
  246. *
  247. * @api
  248. */
  249. #define rccEnableDAC2(lp) rccEnableAPB1(RCC_APB1ENR_DAC2EN, lp)
  250. /**
  251. * @brief Disables the DAC1 peripheral clock.
  252. *
  253. * @api
  254. */
  255. #define rccDisableDAC2() rccDisableAPB1(RCC_APB1ENR_DAC2EN)
  256. /**
  257. * @brief Resets the DAC1 peripheral.
  258. *
  259. * @api
  260. */
  261. #define rccResetDAC2() rccResetAPB1(RCC_APB1RSTR_DAC2RST)
  262. /** @} */
  263. /**
  264. * @name CAN peripherals specific RCC operations
  265. * @{
  266. */
  267. /**
  268. * @brief Enables the CAN1 peripheral clock.
  269. * @note The @p lp parameter is ignored in this family.
  270. *
  271. * @param[in] lp low power enable flag
  272. *
  273. * @api
  274. */
  275. #define rccEnableCAN1(lp) rccEnableAPB1(RCC_APB1ENR_CANEN, lp)
  276. /**
  277. * @brief Disables the CAN1 peripheral clock.
  278. *
  279. * @api
  280. */
  281. #define rccDisableCAN1() rccDisableAPB1(RCC_APB1ENR_CANEN)
  282. /**
  283. * @brief Resets the CAN1 peripheral.
  284. *
  285. * @api
  286. */
  287. #define rccResetCAN1() rccResetAPB1(RCC_APB1RSTR_CANRST)
  288. /** @} */
  289. /**
  290. * @name DMA peripheral specific RCC operations
  291. * @{
  292. */
  293. /**
  294. * @brief Enables the DMA1 peripheral clock.
  295. *
  296. * @param[in] lp low power enable flag
  297. *
  298. * @api
  299. */
  300. #define rccEnableDMA1(lp) rccEnableAHB(RCC_AHBENR_DMA1EN, lp)
  301. /**
  302. * @brief Disables the DMA1 peripheral clock.
  303. *
  304. * @api
  305. */
  306. #define rccDisableDMA1() rccDisableAHB(RCC_AHBENR_DMA1EN)
  307. /**
  308. * @brief Resets the DMA1 peripheral.
  309. *
  310. * @api
  311. */
  312. #define rccResetDMA1() rccResetAHB(RCC_AHBRSTR_DMA1RST)
  313. /**
  314. * @brief Enables the DMA2 peripheral clock.
  315. *
  316. * @param[in] lp low power enable flag
  317. *
  318. * @api
  319. */
  320. #define rccEnableDMA2(lp) rccEnableAHB(RCC_AHBENR_DMA2EN, lp)
  321. /**
  322. * @brief Disables the DMA2 peripheral clock.
  323. *
  324. * @api
  325. */
  326. #define rccDisableDMA2() rccDisableAHB(RCC_AHBENR_DMA2EN)
  327. /**
  328. * @brief Resets the DMA2 peripheral.
  329. *
  330. * @api
  331. */
  332. #define rccResetDMA2() rccResetAHB(RCC_AHBRSTR_DMA2RST)
  333. /** @} */
  334. /**
  335. * @name PWR interface specific RCC operations
  336. * @{
  337. */
  338. /**
  339. * @brief Enables the PWR interface clock.
  340. * @note The @p lp parameter is ignored in this family.
  341. *
  342. * @param[in] lp low power enable flag
  343. *
  344. * @api
  345. */
  346. #define rccEnablePWRInterface(lp) rccEnableAPB1(RCC_APB1ENR_PWREN, lp)
  347. /**
  348. * @brief Disables PWR interface clock.
  349. *
  350. * @api
  351. */
  352. #define rccDisablePWRInterface() rccDisableAPB1(RCC_APB1ENR_PWREN)
  353. /**
  354. * @brief Resets the PWR interface.
  355. *
  356. * @api
  357. */
  358. #define rccResetPWRInterface() rccResetAPB1(RCC_APB1RSTR_PWRRST)
  359. /** @} */
  360. /**
  361. * @name I2C peripherals specific RCC operations
  362. * @{
  363. */
  364. /**
  365. * @brief Enables the I2C1 peripheral clock.
  366. *
  367. * @param[in] lp low power enable flag
  368. *
  369. * @api
  370. */
  371. #define rccEnableI2C1(lp) rccEnableAPB1(RCC_APB1ENR_I2C1EN, lp)
  372. /**
  373. * @brief Disables the I2C1 peripheral clock.
  374. *
  375. * @api
  376. */
  377. #define rccDisableI2C1() rccDisableAPB1(RCC_APB1ENR_I2C1EN)
  378. /**
  379. * @brief Resets the I2C1 peripheral.
  380. *
  381. * @api
  382. */
  383. #define rccResetI2C1() rccResetAPB1(RCC_APB1RSTR_I2C1RST)
  384. /**
  385. * @brief Enables the I2C2 peripheral clock.
  386. *
  387. * @param[in] lp low power enable flag
  388. *
  389. * @api
  390. */
  391. #define rccEnableI2C2(lp) rccEnableAPB1(RCC_APB1ENR_I2C2EN, lp)
  392. /**
  393. * @brief Disables the I2C2 peripheral clock.
  394. *
  395. * @api
  396. */
  397. #define rccDisableI2C2() rccDisableAPB1(RCC_APB1ENR_I2C2EN)
  398. /**
  399. * @brief Resets the I2C2 peripheral.
  400. *
  401. * @api
  402. */
  403. #define rccResetI2C2() rccResetAPB1(RCC_APB1RSTR_I2C2RST)
  404. /** @} */
  405. /**
  406. * @name SPI peripherals specific RCC operations
  407. * @{
  408. */
  409. /**
  410. * @brief Enables the SPI1 peripheral clock.
  411. *
  412. * @param[in] lp low power enable flag
  413. *
  414. * @api
  415. */
  416. #define rccEnableSPI1(lp) rccEnableAPB2(RCC_APB2ENR_SPI1EN, lp)
  417. /**
  418. * @brief Disables the SPI1 peripheral clock.
  419. *
  420. * @api
  421. */
  422. #define rccDisableSPI1() rccDisableAPB2(RCC_APB2ENR_SPI1EN)
  423. /**
  424. * @brief Resets the SPI1 peripheral.
  425. *
  426. * @api
  427. */
  428. #define rccResetSPI1() rccResetAPB2(RCC_APB2RSTR_SPI1RST)
  429. /**
  430. * @brief Enables the SPI2 peripheral clock.
  431. *
  432. * @param[in] lp low power enable flag
  433. *
  434. * @api
  435. */
  436. #define rccEnableSPI2(lp) rccEnableAPB1(RCC_APB1ENR_SPI2EN, lp)
  437. /**
  438. * @brief Disables the SPI2 peripheral clock.
  439. *
  440. * @api
  441. */
  442. #define rccDisableSPI2() rccDisableAPB1(RCC_APB1ENR_SPI2EN)
  443. /**
  444. * @brief Resets the SPI2 peripheral.
  445. *
  446. * @api
  447. */
  448. #define rccResetSPI2() rccResetAPB1(RCC_APB1RSTR_SPI2RST)
  449. /**
  450. * @brief Enables the SPI3 peripheral clock.
  451. * @note The @p lp parameter is ignored in this family.
  452. *
  453. * @param[in] lp low power enable flag
  454. *
  455. * @api
  456. */
  457. #define rccEnableSPI3(lp) rccEnableAPB1(RCC_APB1ENR_SPI3EN, lp)
  458. /**
  459. * @brief Disables the SPI3 peripheral clock.
  460. *
  461. * @api
  462. */
  463. #define rccDisableSPI3() rccDisableAPB1(RCC_APB1ENR_SPI3EN)
  464. /**
  465. * @brief Resets the SPI3 peripheral.
  466. *
  467. * @api
  468. */
  469. #define rccResetSPI3() rccResetAPB1(RCC_APB1RSTR_SPI3RST)
  470. /** @} */
  471. /**
  472. * @name TIM peripherals specific RCC operations
  473. * @{
  474. */
  475. /**
  476. * @brief Enables the TIM1 peripheral clock.
  477. * @note The @p lp parameter is ignored in this family.
  478. *
  479. * @param[in] lp low power enable flag
  480. *
  481. * @api
  482. */
  483. #define rccEnableTIM1(lp) rccEnableAPB2(RCC_APB2ENR_TIM1EN, lp)
  484. /**
  485. * @brief Disables the TIM1 peripheral clock.
  486. *
  487. * @api
  488. */
  489. #define rccDisableTIM1() rccDisableAPB2(RCC_APB2ENR_TIM1EN)
  490. /**
  491. * @brief Resets the TIM1 peripheral.
  492. *
  493. * @api
  494. */
  495. #define rccResetTIM1() rccResetAPB2(RCC_APB2RSTR_TIM1RST)
  496. /**
  497. * @brief Enables the TIM2 peripheral clock.
  498. *
  499. * @param[in] lp low power enable flag
  500. *
  501. * @api
  502. */
  503. #define rccEnableTIM2(lp) rccEnableAPB1(RCC_APB1ENR_TIM2EN, lp)
  504. /**
  505. * @brief Disables the TIM2 peripheral clock.
  506. *
  507. * @api
  508. */
  509. #define rccDisableTIM2() rccDisableAPB1(RCC_APB1ENR_TIM2EN)
  510. /**
  511. * @brief Resets the TIM2 peripheral.
  512. *
  513. * @api
  514. */
  515. #define rccResetTIM2() rccResetAPB1(RCC_APB1RSTR_TIM2RST)
  516. /**
  517. * @brief Enables the TIM3 peripheral clock.
  518. *
  519. * @param[in] lp low power enable flag
  520. *
  521. * @api
  522. */
  523. #define rccEnableTIM3(lp) rccEnableAPB1(RCC_APB1ENR_TIM3EN, lp)
  524. /**
  525. * @brief Disables the TIM3 peripheral clock.
  526. *
  527. * @api
  528. */
  529. #define rccDisableTIM3() rccDisableAPB1(RCC_APB1ENR_TIM3EN)
  530. /**
  531. * @brief Resets the TIM3 peripheral.
  532. *
  533. * @api
  534. */
  535. #define rccResetTIM3() rccResetAPB1(RCC_APB1RSTR_TIM3RST)
  536. /**
  537. * @brief Enables the TIM4 peripheral clock.
  538. *
  539. * @param[in] lp low power enable flag
  540. *
  541. * @api
  542. */
  543. #define rccEnableTIM4(lp) rccEnableAPB1(RCC_APB1ENR_TIM4EN, lp)
  544. /**
  545. * @brief Disables the TIM4 peripheral clock.
  546. *
  547. * @api
  548. */
  549. #define rccDisableTIM4() rccDisableAPB1(RCC_APB1ENR_TIM4EN)
  550. /**
  551. * @brief Resets the TIM4 peripheral.
  552. *
  553. * @api
  554. */
  555. #define rccResetTIM4() rccResetAPB1(RCC_APB1RSTR_TIM4RST)
  556. /**
  557. * @brief Enables the TIM6 peripheral clock.
  558. *
  559. * @param[in] lp low power enable flag
  560. *
  561. * @api
  562. */
  563. #define rccEnableTIM6(lp) rccEnableAPB1(RCC_APB1ENR_TIM6EN, lp)
  564. /**
  565. * @brief Disables the TIM6 peripheral clock.
  566. *
  567. * @api
  568. */
  569. #define rccDisableTIM6() rccDisableAPB1(RCC_APB1ENR_TIM6EN)
  570. /**
  571. * @brief Resets the TIM6 peripheral.
  572. *
  573. * @api
  574. */
  575. #define rccResetTIM6() rccResetAPB1(RCC_APB1RSTR_TIM6RST)
  576. /**
  577. * @brief Enables the TIM7 peripheral clock.
  578. *
  579. * @param[in] lp low power enable flag
  580. *
  581. * @api
  582. */
  583. #define rccEnableTIM7(lp) rccEnableAPB1(RCC_APB1ENR_TIM7EN, lp)
  584. /**
  585. * @brief Disables the TIM7 peripheral clock.
  586. *
  587. * @api
  588. */
  589. #define rccDisableTIM7() rccDisableAPB1(RCC_APB1ENR_TIM7EN)
  590. /**
  591. * @brief Resets the TIM7 peripheral.
  592. *
  593. * @api
  594. */
  595. #define rccResetTIM7() rccResetAPB1(RCC_APB1RSTR_TIM7RST)
  596. /**
  597. * @brief Enables the TIM8 peripheral clock.
  598. * @note The @p lp parameter is ignored in this family.
  599. *
  600. * @param[in] lp low power enable flag
  601. *
  602. * @api
  603. */
  604. #define rccEnableTIM8(lp) rccEnableAPB2(RCC_APB2ENR_TIM8EN, lp)
  605. /**
  606. * @brief Disables the TIM8 peripheral clock.
  607. *
  608. * @api
  609. */
  610. #define rccDisableTIM8() rccDisableAPB2(RCC_APB2ENR_TIM8EN)
  611. /**
  612. * @brief Resets the TIM8 peripheral.
  613. *
  614. * @api
  615. */
  616. #define rccResetTIM8() rccResetAPB2(RCC_APB2RSTR_TIM8RST)
  617. /**
  618. * @brief Enables the TIM15 peripheral clock.
  619. *
  620. * @param[in] lp low power enable flag
  621. *
  622. * @api
  623. */
  624. #define rccEnableTIM15(lp) rccEnableAPB2(RCC_APB2ENR_TIM15EN, lp)
  625. /**
  626. * @brief Disables the TIM15 peripheral clock.
  627. *
  628. * @api
  629. */
  630. #define rccDisableTIM15() rccDisableAPB2(RCC_APB2ENR_TIM15EN)
  631. /**
  632. * @brief Resets the TIM15 peripheral.
  633. *
  634. * @api
  635. */
  636. #define rccResetTIM15() rccResetAPB2(RCC_APB2RSTR_TIM15RST)
  637. /**
  638. * @brief Enables the TIM16 peripheral clock.
  639. *
  640. * @param[in] lp low power enable flag
  641. *
  642. * @api
  643. */
  644. #define rccEnableTIM16(lp) rccEnableAPB2(RCC_APB2ENR_TIM16EN, lp)
  645. /**
  646. * @brief Disables the TIM16 peripheral clock.
  647. *
  648. * @api
  649. */
  650. #define rccDisableTIM16() rccDisableAPB2(RCC_APB2ENR_TIM16EN)
  651. /**
  652. * @brief Resets the TIM16 peripheral.
  653. *
  654. * @api
  655. */
  656. #define rccResetTIM16() rccResetAPB2(RCC_APB2RSTR_TIM16RST)
  657. /**
  658. * @brief Enables the TIM17 peripheral clock.
  659. *
  660. * @param[in] lp low power enable flag
  661. *
  662. * @api
  663. */
  664. #define rccEnableTIM17(lp) rccEnableAPB2(RCC_APB2ENR_TIM17EN, lp)
  665. /**
  666. * @brief Disables the TIM17 peripheral clock.
  667. *
  668. * @api
  669. */
  670. #define rccDisableTIM17() rccDisableAPB2(RCC_APB2ENR_TIM17EN)
  671. /**
  672. * @brief Resets the TIM17 peripheral.
  673. *
  674. * @api
  675. */
  676. #define rccResetTIM17() rccResetAPB2(RCC_APB2RSTR_TIM17RST)
  677. /**
  678. * @brief Enables the TIM20 peripheral clock.
  679. *
  680. * @param[in] lp low power enable flag
  681. *
  682. * @api
  683. */
  684. #define rccEnableTIM20(lp) rccEnableAPB2(RCC_APB2ENR_TIM20EN, lp)
  685. /**
  686. * @brief Disables the TIM20 peripheral clock.
  687. *
  688. * @api
  689. */
  690. #define rccDisableTIM20(lp) rccDisableAPB2(RCC_APB2ENR_TIM20EN)
  691. /**
  692. * @brief Resets the TIM20 peripheral.
  693. *
  694. * @api
  695. */
  696. #define rccResetTIM20() rccResetAPB2(RCC_APB2RSTR_TIM20RST)
  697. /** @} */
  698. /**
  699. * @name HRTIM peripheral specific RCC operations
  700. * @{
  701. */
  702. /**
  703. * @brief Enables the HRTIM1 peripheral clock.
  704. * @note The @p lp parameter is ignored in this family.
  705. *
  706. * @param[in] lp low power enable flag
  707. *
  708. * @api
  709. */
  710. #define rccEnableHRTIM1(lp) rccEnableAPB2(RCC_APB2ENR_HRTIM1EN, lp)
  711. /**
  712. * @brief Disables the HRTIM1 peripheral clock.
  713. *
  714. * @api
  715. */
  716. #define rccDisableHRTIM1(lp) rccDisableAPB2(RCC_APB2ENR_HRTIM1EN)
  717. /**
  718. * @brief Resets the HRTIM1 peripheral.
  719. *
  720. * @api
  721. */
  722. #define rccResetHRTIM1() rccResetAPB2(RCC_APB2RSTR_HRTIM1RST)
  723. /** @} */
  724. /**
  725. * @name USART/UART peripherals specific RCC operations
  726. * @{
  727. */
  728. /**
  729. * @brief Enables the USART1 peripheral clock.
  730. *
  731. * @param[in] lp low power enable flag
  732. *
  733. * @api
  734. */
  735. #define rccEnableUSART1(lp) rccEnableAPB2(RCC_APB2ENR_USART1EN, lp)
  736. /**
  737. * @brief Disables the USART1 peripheral clock.
  738. *
  739. * @api
  740. */
  741. #define rccDisableUSART1() rccDisableAPB2(RCC_APB2ENR_USART1EN)
  742. /**
  743. * @brief Resets the USART1 peripheral.
  744. *
  745. * @api
  746. */
  747. #define rccResetUSART1() rccResetAPB2(RCC_APB2RSTR_USART1RST)
  748. /**
  749. * @brief Enables the USART2 peripheral clock.
  750. *
  751. * @param[in] lp low power enable flag
  752. *
  753. * @api
  754. */
  755. #define rccEnableUSART2(lp) rccEnableAPB1(RCC_APB1ENR_USART2EN, lp)
  756. /**
  757. * @brief Disables the USART2 peripheral clock.
  758. *
  759. * @api
  760. */
  761. #define rccDisableUSART2() rccDisableAPB1(RCC_APB1ENR_USART2EN)
  762. /**
  763. * @brief Resets the USART2 peripheral.
  764. *
  765. * @api
  766. */
  767. #define rccResetUSART2() rccResetAPB1(RCC_APB1RSTR_USART2RST)
  768. /**
  769. * @brief Enables the USART3 peripheral clock.
  770. *
  771. * @param[in] lp low power enable flag
  772. *
  773. * @api
  774. */
  775. #define rccEnableUSART3(lp) rccEnableAPB1(RCC_APB1ENR_USART3EN, lp)
  776. /**
  777. * @brief Disables the USART3 peripheral clock.
  778. *
  779. * @api
  780. */
  781. #define rccDisableUSART3() rccDisableAPB1(RCC_APB1ENR_USART3EN)
  782. /**
  783. * @brief Resets the USART3 peripheral.
  784. *
  785. * @api
  786. */
  787. #define rccResetUSART3() rccResetAPB1(RCC_APB1RSTR_USART3RST)
  788. /**
  789. * @brief Enables the UART4 peripheral clock.
  790. * @note The @p lp parameter is ignored in this family.
  791. *
  792. * @param[in] lp low power enable flag
  793. *
  794. * @api
  795. */
  796. #define rccEnableUART4(lp) rccEnableAPB1(RCC_APB1ENR_UART4EN, lp)
  797. /**
  798. * @brief Disables the UART4 peripheral clock.
  799. *
  800. * @api
  801. */
  802. #define rccDisableUART4() rccDisableAPB1(RCC_APB1ENR_UART4EN)
  803. /**
  804. * @brief Resets the UART4 peripheral.
  805. *
  806. * @api
  807. */
  808. #define rccResetUART4() rccResetAPB1(RCC_APB1RSTR_UART4RST)
  809. /**
  810. * @brief Enables the UART5 peripheral clock.
  811. * @note The @p lp parameter is ignored in this family.
  812. *
  813. * @param[in] lp low power enable flag
  814. *
  815. * @api
  816. */
  817. #define rccEnableUART5(lp) rccEnableAPB1(RCC_APB1ENR_UART5EN, lp)
  818. /**
  819. * @brief Disables the UART5 peripheral clock.
  820. *
  821. * @api
  822. */
  823. #define rccDisableUART5() rccDisableAPB1(RCC_APB1ENR_UART5EN)
  824. /**
  825. * @brief Resets the UART5 peripheral.
  826. *
  827. * @api
  828. */
  829. #define rccResetUART5() rccResetAPB1(RCC_APB1RSTR_UART5RST)
  830. /** @} */
  831. /**
  832. * @name USB peripheral specific RCC operations
  833. * @{
  834. */
  835. /**
  836. * @brief Enables the USB peripheral clock.
  837. *
  838. * @param[in] lp low power enable flag
  839. *
  840. * @api
  841. */
  842. #define rccEnableUSB(lp) rccEnableAPB1(RCC_APB1ENR_USBEN, lp)
  843. /**
  844. * @brief Disables the USB peripheral clock.
  845. *
  846. * @api
  847. */
  848. #define rccDisableUSB() rccDisableAPB1(RCC_APB1ENR_USBEN)
  849. /**
  850. * @brief Resets the USB peripheral.
  851. *
  852. * @api
  853. */
  854. #define rccResetUSB() rccResetAPB1(RCC_APB1RSTR_USBRST)
  855. /** @} */
  856. /**
  857. * @name FSMC peripherals specific RCC operations
  858. * @{
  859. */
  860. /**
  861. * @brief Enables the FMC peripheral clock.
  862. *
  863. * @param[in] lp low power enable flag
  864. *
  865. * @api
  866. */
  867. #define rccEnableFSMC(lp) rccEnableAHB(RCC_AHBENR_FMCEN, lp)
  868. /**
  869. * @brief Disables the FMC peripheral clock.
  870. *
  871. * @api
  872. */
  873. #define rccDisableFSMC() rccDisableAHB(RCC_AHBENR_FMCEN)
  874. /** @} */
  875. /**
  876. * @name CRC peripherals specific RCC operations
  877. * @{
  878. */
  879. /**
  880. * @brief Enables the CRC peripheral clock.
  881. *
  882. * @param[in] lp low power enable flag
  883. *
  884. * @api
  885. */
  886. #define rccEnableCRC(lp) rccEnableAHB(RCC_AHBENR_CRCEN, lp)
  887. /**
  888. * @brief Disables the CRC peripheral clock.
  889. *
  890. * @api
  891. */
  892. #define rccDisableCRC() rccDisableAHB(RCC_AHBENR_CRCEN)
  893. /** @} */
  894. /*===========================================================================*/
  895. /* External declarations. */
  896. /*===========================================================================*/
  897. #ifdef __cplusplus
  898. extern "C" {
  899. #endif
  900. #ifdef __cplusplus
  901. }
  902. #endif
  903. #endif /* STM32_RCC_H */
  904. /** @} */