stm32_rcc.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  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 STM32F1xx/stm32_rcc.h
  15. * @brief RCC helper driver header.
  16. * @note This file requires definitions from the ST header file
  17. * @p stm32f10x.h.
  18. *
  19. * @addtogroup STM32F1xx_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. * @note The @p lp parameter is ignored in this family.
  46. *
  47. * @param[in] mask APB1 peripherals mask
  48. * @param[in] lp low power enable flag
  49. *
  50. * @api
  51. */
  52. #define rccEnableAPB1(mask, lp) { \
  53. RCC->APB1ENR |= (mask); \
  54. (void)RCC->APB1ENR; \
  55. }
  56. /**
  57. * @brief Disables the clock of one or more peripheral on the APB1 bus.
  58. * @note The @p lp parameter is ignored in this family.
  59. *
  60. * @param[in] mask APB1 peripherals mask
  61. *
  62. * @api
  63. */
  64. #define rccDisableAPB1(mask) { \
  65. RCC->APB1ENR &= ~(mask); \
  66. (void)RCC->APB1ENR; \
  67. }
  68. /**
  69. * @brief Resets one or more peripheral on the APB1 bus.
  70. *
  71. * @param[in] mask APB1 peripherals mask
  72. *
  73. * @api
  74. */
  75. #define rccResetAPB1(mask) { \
  76. RCC->APB1RSTR |= (mask); \
  77. RCC->APB1RSTR &= ~(mask); \
  78. (void)RCC->APB1RSTR; \
  79. }
  80. /**
  81. * @brief Enables the clock of one or more peripheral on the APB2 bus.
  82. * @note The @p lp parameter is ignored in this family.
  83. *
  84. * @param[in] mask APB2 peripherals mask
  85. * @param[in] lp low power enable flag
  86. *
  87. * @api
  88. */
  89. #define rccEnableAPB2(mask, lp) { \
  90. RCC->APB2ENR |= (mask); \
  91. (void)RCC->APB2ENR; \
  92. }
  93. /**
  94. * @brief Disables the clock of one or more peripheral on the APB2 bus.
  95. * @note The @p lp parameter is ignored in this family.
  96. *
  97. * @param[in] mask APB2 peripherals mask
  98. *
  99. * @api
  100. */
  101. #define rccDisableAPB2(mask) { \
  102. RCC->APB2ENR &= ~(mask); \
  103. (void)RCC->APB2ENR; \
  104. }
  105. /**
  106. * @brief Resets one or more peripheral on the APB2 bus.
  107. *
  108. * @param[in] mask APB2 peripherals mask
  109. *
  110. * @api
  111. */
  112. #define rccResetAPB2(mask) { \
  113. RCC->APB2RSTR |= (mask); \
  114. RCC->APB2RSTR &= ~(mask); \
  115. (void)RCC->APB2RSTR; \
  116. }
  117. /**
  118. * @brief Enables the clock of one or more peripheral on the AHB bus.
  119. * @note The @p lp parameter is ignored in this family.
  120. *
  121. * @param[in] mask AHB peripherals mask
  122. * @param[in] lp low power enable flag
  123. *
  124. * @api
  125. */
  126. #define rccEnableAHB(mask, lp) { \
  127. RCC->AHBENR |= (mask); \
  128. (void)RCC->AHBENR; \
  129. }
  130. /**
  131. * @brief Disables the clock of one or more peripheral on the AHB bus.
  132. * @note The @p lp parameter is ignored in this family.
  133. *
  134. * @param[in] mask AHB peripherals mask
  135. *
  136. * @api
  137. */
  138. #define rccDisableAHB(mask) { \
  139. RCC->AHBENR &= ~(mask); \
  140. (void)RCC->AHBENR; \
  141. }
  142. /**
  143. * @brief Resets one or more peripheral on the AHB bus.
  144. *
  145. * @param[in] mask AHB peripherals mask
  146. *
  147. * @api
  148. */
  149. #define rccResetAHB(mask) { \
  150. RCC->AHBRSTR |= (mask); \
  151. RCC->AHBRSTR &= ~(mask); \
  152. (void)RCC->AHBRSTR; \
  153. }
  154. /** @} */
  155. /**
  156. * @name ADC peripherals specific RCC operations
  157. * @{
  158. */
  159. /**
  160. * @brief Enables the ADC1 peripheral clock.
  161. * @note The @p lp parameter is ignored in this family.
  162. *
  163. * @param[in] lp low power enable flag
  164. *
  165. * @api
  166. */
  167. #define rccEnableADC1(lp) rccEnableAPB2(RCC_APB2ENR_ADC1EN, lp)
  168. /**
  169. * @brief Disables the ADC1 peripheral clock.
  170. *
  171. * @api
  172. */
  173. #define rccDisableADC1() rccDisableAPB2(RCC_APB2ENR_ADC1EN)
  174. /**
  175. * @brief Resets the ADC1 peripheral.
  176. *
  177. * @api
  178. */
  179. #define rccResetADC1() rccResetAPB2(RCC_APB2RSTR_ADC1RST)
  180. /** @} */
  181. /**
  182. * @name DAC peripheral specific RCC operations
  183. * @{
  184. */
  185. /**
  186. * @brief Enables the DAC1 peripheral clock.
  187. *
  188. * @param[in] lp low power enable flag
  189. *
  190. * @api
  191. */
  192. #define rccEnableDAC1(lp) rccEnableAPB1(RCC_APB1ENR_DACEN, lp)
  193. /**
  194. * @brief Disables the DAC1 peripheral clock.
  195. *
  196. * @api
  197. */
  198. #define rccDisableDAC1() rccDisableAPB1(RCC_APB1ENR_DACEN)
  199. /**
  200. * @brief Resets the DAC1 peripheral.
  201. *
  202. * @api
  203. */
  204. #define rccResetDAC1() rccResetAPB1(RCC_APB1RSTR_DACRST)
  205. /** @} */
  206. /**
  207. * @name Backup domain interface specific RCC operations
  208. * @{
  209. */
  210. /**
  211. * @brief Enables the BKP interface clock.
  212. * @note The @p lp parameter is ignored in this family.
  213. *
  214. * @param[in] lp low power enable flag
  215. *
  216. * @api
  217. */
  218. #define rccEnableBKPInterface(lp) rccEnableAPB1((RCC_APB1ENR_BKPEN), lp)
  219. /**
  220. * @brief Disables BKP interface clock.
  221. *
  222. * @api
  223. */
  224. #define rccDisableBKPInterface() rccDisableAPB1(RCC_APB1ENR_BKPEN)
  225. /**
  226. * @brief Resets the Backup Domain interface.
  227. *
  228. * @api
  229. */
  230. #define rccResetBKPInterface() rccResetAPB1(RCC_APB1ENR_BKPRST)
  231. /**
  232. * @brief Resets the entire Backup Domain.
  233. *
  234. * @api
  235. */
  236. #define rccResetBKP() (RCC->BDCR |= RCC_BDCR_BDRST)
  237. /** @} */
  238. /**
  239. * @name PWR interface specific RCC operations
  240. * @{
  241. */
  242. /**
  243. * @brief Enables the PWR interface clock.
  244. * @note The @p lp parameter is ignored in this family.
  245. *
  246. * @param[in] lp low power enable flag
  247. *
  248. * @api
  249. */
  250. #define rccEnablePWRInterface(lp) rccEnableAPB1(RCC_APB1ENR_PWREN, lp)
  251. /**
  252. * @brief Disables PWR interface clock.
  253. *
  254. * @api
  255. */
  256. #define rccDisablePWRInterface() rccDisableAPB1(RCC_APB1ENR_PWREN)
  257. /**
  258. * @brief Resets the PWR interface.
  259. *
  260. * @api
  261. */
  262. #define rccResetPWRInterface() rccResetAPB1(RCC_APB1RSTR_PWRRST)
  263. /** @} */
  264. /**
  265. * @name CAN peripherals specific RCC operations
  266. * @{
  267. */
  268. /**
  269. * @brief Enables the CAN1 peripheral clock.
  270. * @note The @p lp parameter is ignored in this family.
  271. *
  272. * @param[in] lp low power enable flag
  273. *
  274. * @api
  275. */
  276. #define rccEnableCAN1(lp) rccEnableAPB1(RCC_APB1ENR_CAN1EN, lp)
  277. /**
  278. * @brief Disables the CAN1 peripheral clock.
  279. *
  280. * @api
  281. */
  282. #define rccDisableCAN1() rccDisableAPB1(RCC_APB1ENR_CAN1EN)
  283. /**
  284. * @brief Resets the CAN1 peripheral.
  285. *
  286. * @api
  287. */
  288. #define rccResetCAN1() rccResetAPB1(RCC_APB1RSTR_CAN1RST)
  289. /**
  290. * @brief Enables the CAN2 peripheral clock.
  291. *
  292. * @param[in] lp low power enable flag
  293. *
  294. * @api
  295. */
  296. #define rccEnableCAN2(lp) rccEnableAPB1(RCC_APB1ENR_CAN2EN, lp)
  297. /**
  298. * @brief Disables the CAN2 peripheral clock.
  299. *
  300. * @api
  301. */
  302. #define rccDisableCAN2() rccDisableAPB1(RCC_APB1ENR_CAN2EN)
  303. /**
  304. * @brief Resets the CAN2 peripheral.
  305. *
  306. * @api
  307. */
  308. #define rccResetCAN2() rccResetAPB1(RCC_APB1RSTR_CAN2RST)
  309. /** @} */
  310. /**
  311. * @name DMA peripherals specific RCC operations
  312. * @{
  313. */
  314. /**
  315. * @brief Enables the DMA1 peripheral clock.
  316. * @note The @p lp parameter is ignored in this family.
  317. *
  318. * @param[in] lp low power enable flag
  319. *
  320. * @api
  321. */
  322. #define rccEnableDMA1(lp) rccEnableAHB(RCC_AHBENR_DMA1EN, lp)
  323. /**
  324. * @brief Disables the DMA1 peripheral clock.
  325. *
  326. * @api
  327. */
  328. #define rccDisableDMA1() rccDisableAHB(RCC_AHBENR_DMA1EN)
  329. /**
  330. * @brief Resets the DMA1 peripheral.
  331. * @note Not supported in this family, does nothing.
  332. *
  333. * @api
  334. */
  335. #define rccResetDMA1()
  336. /**
  337. * @brief Enables the DMA2 peripheral clock.
  338. * @note The @p lp parameter is ignored in this family.
  339. *
  340. * @param[in] lp low power enable flag
  341. *
  342. * @api
  343. */
  344. #define rccEnableDMA2(lp) rccEnableAHB(RCC_AHBENR_DMA2EN, lp)
  345. /**
  346. * @brief Disables the DMA2 peripheral clock.
  347. *
  348. * @api
  349. */
  350. #define rccDisableDMA2() rccDisableAHB(RCC_AHBENR_DMA2EN)
  351. /**
  352. * @brief Resets the DMA1 peripheral.
  353. * @note Not supported in this family, does nothing.
  354. *
  355. * @api
  356. */
  357. #define rccResetDMA2()
  358. /** @} */
  359. /**
  360. * @name ETH peripheral specific RCC operations
  361. * @{
  362. */
  363. /**
  364. * @brief Enables the ETH peripheral clock.
  365. * @note The @p lp parameter is ignored in this family.
  366. *
  367. * @param[in] lp low power enable flag
  368. *
  369. * @api
  370. */
  371. #define rccEnableETH(lp) rccEnableAHB(RCC_AHBENR_ETHMACEN | \
  372. RCC_AHBENR_ETHMACTXEN | \
  373. RCC_AHBENR_ETHMACRXEN, lp)
  374. /**
  375. * @brief Disables the ETH peripheral clock.
  376. * @note The @p lp parameter is ignored in this family.
  377. *
  378. * @param[in] lp low power enable flag
  379. *
  380. * @api
  381. */
  382. #define rccDisableETH() rccDisableAHB(RCC_AHBENR_ETHMACEN | \
  383. RCC_AHBENR_ETHMACTXEN | \
  384. RCC_AHBENR_ETHMACRXEN)
  385. /**
  386. * @brief Resets the ETH peripheral.
  387. *
  388. * @api
  389. */
  390. #define rccResetETH() rccResetAHB(RCC_AHBRSTR_ETHMACRST)
  391. /** @} */
  392. /**
  393. * @name I2C peripherals specific RCC operations
  394. * @{
  395. */
  396. /**
  397. * @brief Enables the I2C1 peripheral clock.
  398. * @note The @p lp parameter is ignored in this family.
  399. *
  400. * @param[in] lp low power enable flag
  401. *
  402. * @api
  403. */
  404. #define rccEnableI2C1(lp) rccEnableAPB1(RCC_APB1ENR_I2C1EN, lp)
  405. /**
  406. * @brief Disables the I2C1 peripheral clock.
  407. *
  408. * @api
  409. */
  410. #define rccDisableI2C1() rccDisableAPB1(RCC_APB1ENR_I2C1EN)
  411. /**
  412. * @brief Resets the I2C1 peripheral.
  413. *
  414. * @api
  415. */
  416. #define rccResetI2C1() rccResetAPB1(RCC_APB1RSTR_I2C1RST)
  417. /**
  418. * @brief Enables the I2C2 peripheral clock.
  419. * @note The @p lp parameter is ignored in this family.
  420. *
  421. * @param[in] lp low power enable flag
  422. *
  423. * @api
  424. */
  425. #define rccEnableI2C2(lp) rccEnableAPB1(RCC_APB1ENR_I2C2EN, lp)
  426. /**
  427. * @brief Disables the I2C2 peripheral clock.
  428. *
  429. * @api
  430. */
  431. #define rccDisableI2C2() rccDisableAPB1(RCC_APB1ENR_I2C2EN)
  432. /**
  433. * @brief Resets the I2C2 peripheral.
  434. *
  435. * @api
  436. */
  437. #define rccResetI2C2() rccResetAPB1(RCC_APB1RSTR_I2C2RST)
  438. /** @} */
  439. /**
  440. * @name OTG peripherals specific RCC operations
  441. * @{
  442. */
  443. /**
  444. * @brief Enables the OTG_FS peripheral clock.
  445. *
  446. * @param[in] lp low power enable flag
  447. *
  448. * @api
  449. */
  450. #define rccEnableOTG_FS(lp) rccEnableAHB(RCC_AHBENR_OTGFSEN, lp)
  451. /**
  452. * @brief Disables the OTG_FS peripheral clock.
  453. *
  454. * @api
  455. */
  456. #define rccDisableOTG_FS() rccDisableAHB(RCC_AHBENR_OTGFSEN)
  457. /**
  458. * @brief Resets the OTG_FS peripheral.
  459. *
  460. * @api
  461. */
  462. #define rccResetOTG_FS() rccResetAHB(RCC_AHBRSTR_OTGFSRST)
  463. /** @} */
  464. /**
  465. * @name SDIO peripheral specific RCC operations
  466. * @{
  467. */
  468. /**
  469. * @brief Enables the SDIO peripheral clock.
  470. * @note The @p lp parameter is ignored in this family.
  471. *
  472. * @param[in] lp low power enable flag
  473. *
  474. * @api
  475. */
  476. #define rccEnableSDIO(lp) rccEnableAHB(RCC_AHBENR_SDIOEN, lp)
  477. /**
  478. * @brief Disables the SDIO peripheral clock.
  479. *
  480. * @api
  481. */
  482. #define rccDisableSDIO() rccDisableAHB(RCC_AHBENR_SDIOEN)
  483. /**
  484. * @brief Resets the SDIO peripheral.
  485. * @note Not supported in this family, does nothing.
  486. *
  487. * @api
  488. */
  489. #define rccResetSDIO()
  490. /** @} */
  491. /**
  492. * @name SPI peripherals specific RCC operations
  493. * @{
  494. */
  495. /**
  496. * @brief Enables the SPI1 peripheral clock.
  497. * @note The @p lp parameter is ignored in this family.
  498. *
  499. * @param[in] lp low power enable flag
  500. *
  501. * @api
  502. */
  503. #define rccEnableSPI1(lp) rccEnableAPB2(RCC_APB2ENR_SPI1EN, lp)
  504. /**
  505. * @brief Disables the SPI1 peripheral clock.
  506. *
  507. * @api
  508. */
  509. #define rccDisableSPI1() rccDisableAPB2(RCC_APB2ENR_SPI1EN)
  510. /**
  511. * @brief Resets the SPI1 peripheral.
  512. *
  513. * @api
  514. */
  515. #define rccResetSPI1() rccResetAPB2(RCC_APB2RSTR_SPI1RST)
  516. /**
  517. * @brief Enables the SPI2 peripheral clock.
  518. * @note The @p lp parameter is ignored in this family.
  519. *
  520. * @param[in] lp low power enable flag
  521. *
  522. * @api
  523. */
  524. #define rccEnableSPI2(lp) rccEnableAPB1(RCC_APB1ENR_SPI2EN, lp)
  525. /**
  526. * @brief Disables the SPI2 peripheral clock.
  527. *
  528. * @api
  529. */
  530. #define rccDisableSPI2() rccDisableAPB1(RCC_APB1ENR_SPI2EN)
  531. /**
  532. * @brief Resets the SPI2 peripheral.
  533. *
  534. * @api
  535. */
  536. #define rccResetSPI2() rccResetAPB1(RCC_APB1RSTR_SPI2RST)
  537. /**
  538. * @brief Enables the SPI3 peripheral clock.
  539. * @note The @p lp parameter is ignored in this family.
  540. *
  541. * @param[in] lp low power enable flag
  542. *
  543. * @api
  544. */
  545. #define rccEnableSPI3(lp) rccEnableAPB1(RCC_APB1ENR_SPI3EN, lp)
  546. /**
  547. * @brief Disables the SPI3 peripheral clock.
  548. *
  549. * @api
  550. */
  551. #define rccDisableSPI3() rccDisableAPB1(RCC_APB1ENR_SPI3EN)
  552. /**
  553. * @brief Resets the SPI3 peripheral.
  554. *
  555. * @api
  556. */
  557. #define rccResetSPI3() rccResetAPB1(RCC_APB1RSTR_SPI3RST)
  558. /** @} */
  559. /**
  560. * @name TIM peripherals specific RCC operations
  561. * @{
  562. */
  563. /**
  564. * @brief Enables the TIM1 peripheral clock.
  565. * @note The @p lp parameter is ignored in this family.
  566. *
  567. * @param[in] lp low power enable flag
  568. *
  569. * @api
  570. */
  571. #define rccEnableTIM1(lp) rccEnableAPB2(RCC_APB2ENR_TIM1EN, lp)
  572. /**
  573. * @brief Disables the TIM1 peripheral clock.
  574. *
  575. * @api
  576. */
  577. #define rccDisableTIM1() rccDisableAPB2(RCC_APB2ENR_TIM1EN)
  578. /**
  579. * @brief Resets the TIM1 peripheral.
  580. *
  581. * @api
  582. */
  583. #define rccResetTIM1() rccResetAPB2(RCC_APB2RSTR_TIM1RST)
  584. /**
  585. * @brief Enables the TIM2 peripheral clock.
  586. * @note The @p lp parameter is ignored in this family.
  587. *
  588. * @param[in] lp low power enable flag
  589. *
  590. * @api
  591. */
  592. #define rccEnableTIM2(lp) rccEnableAPB1(RCC_APB1ENR_TIM2EN, lp)
  593. /**
  594. * @brief Disables the TIM2 peripheral clock.
  595. *
  596. * @api
  597. */
  598. #define rccDisableTIM2() rccDisableAPB1(RCC_APB1ENR_TIM2EN)
  599. /**
  600. * @brief Resets the TIM2 peripheral.
  601. *
  602. * @api
  603. */
  604. #define rccResetTIM2() rccResetAPB1(RCC_APB1RSTR_TIM2RST)
  605. /**
  606. * @brief Enables the TIM3 peripheral clock.
  607. * @note The @p lp parameter is ignored in this family.
  608. *
  609. * @param[in] lp low power enable flag
  610. *
  611. * @api
  612. */
  613. #define rccEnableTIM3(lp) rccEnableAPB1(RCC_APB1ENR_TIM3EN, lp)
  614. /**
  615. * @brief Disables the TIM3 peripheral clock.
  616. *
  617. * @api
  618. */
  619. #define rccDisableTIM3() rccDisableAPB1(RCC_APB1ENR_TIM3EN)
  620. /**
  621. * @brief Resets the TIM3 peripheral.
  622. *
  623. * @api
  624. */
  625. #define rccResetTIM3() rccResetAPB1(RCC_APB1RSTR_TIM3RST)
  626. /**
  627. * @brief Enables the TIM4 peripheral clock.
  628. * @note The @p lp parameter is ignored in this family.
  629. *
  630. * @param[in] lp low power enable flag
  631. *
  632. * @api
  633. */
  634. #define rccEnableTIM4(lp) rccEnableAPB1(RCC_APB1ENR_TIM4EN, lp)
  635. /**
  636. * @brief Disables the TIM4 peripheral clock.
  637. *
  638. * @api
  639. */
  640. #define rccDisableTIM4() rccDisableAPB1(RCC_APB1ENR_TIM4EN)
  641. /**
  642. * @brief Resets the TIM4 peripheral.
  643. *
  644. * @api
  645. */
  646. #define rccResetTIM4() rccResetAPB1(RCC_APB1RSTR_TIM4RST)
  647. /**
  648. * @brief Enables the TIM5 peripheral clock.
  649. * @note The @p lp parameter is ignored in this family.
  650. *
  651. * @param[in] lp low power enable flag
  652. *
  653. * @api
  654. */
  655. #define rccEnableTIM5(lp) rccEnableAPB1(RCC_APB1ENR_TIM5EN, lp)
  656. /**
  657. * @brief Disables the TIM5 peripheral clock.
  658. *
  659. * @api
  660. */
  661. #define rccDisableTIM5() rccDisableAPB1(RCC_APB1ENR_TIM5EN)
  662. /**
  663. * @brief Resets the TIM5 peripheral.
  664. *
  665. * @api
  666. */
  667. #define rccResetTIM5() rccResetAPB1(RCC_APB1RSTR_TIM5RST)
  668. /**
  669. * @brief Enables the TIM6 peripheral clock.
  670. *
  671. * @param[in] lp low power enable flag
  672. *
  673. * @api
  674. */
  675. #define rccEnableTIM6(lp) rccEnableAPB1(RCC_APB1ENR_TIM6EN, lp)
  676. /**
  677. * @brief Disables the TIM6 peripheral clock.
  678. *
  679. * @api
  680. */
  681. #define rccDisableTIM6() rccDisableAPB1(RCC_APB1ENR_TIM6EN)
  682. /**
  683. * @brief Resets the TIM6 peripheral.
  684. *
  685. * @api
  686. */
  687. #define rccResetTIM6() rccResetAPB1(RCC_APB1RSTR_TIM6RST)
  688. /**
  689. * @brief Enables the TIM7 peripheral clock.
  690. *
  691. * @param[in] lp low power enable flag
  692. *
  693. * @api
  694. */
  695. #define rccEnableTIM7(lp) rccEnableAPB1(RCC_APB1ENR_TIM7EN, lp)
  696. /**
  697. * @brief Disables the TIM7 peripheral clock.
  698. *
  699. * @api
  700. */
  701. #define rccDisableTIM7() rccDisableAPB1(RCC_APB1ENR_TIM7EN)
  702. /**
  703. * @brief Resets the TIM7 peripheral.
  704. *
  705. * @api
  706. */
  707. #define rccResetTIM7() rccResetAPB1(RCC_APB1RSTR_TIM7RST)
  708. /**
  709. * @brief Enables the TIM8 peripheral clock.
  710. * @note The @p lp parameter is ignored in this family.
  711. *
  712. * @param[in] lp low power enable flag
  713. *
  714. * @api
  715. */
  716. #define rccEnableTIM8(lp) rccEnableAPB2(RCC_APB2ENR_TIM8EN, lp)
  717. /**
  718. * @brief Disables the TIM8 peripheral clock.
  719. *
  720. * @api
  721. */
  722. #define rccDisableTIM8() rccDisableAPB2(RCC_APB2ENR_TIM8EN)
  723. /**
  724. * @brief Resets the TIM8 peripheral.
  725. *
  726. * @api
  727. */
  728. #define rccResetTIM8() rccResetAPB2(RCC_APB2RSTR_TIM8RST)
  729. /**
  730. * @brief Enables the TIM9 peripheral clock.
  731. * @note The @p lp parameter is ignored in this family.
  732. *
  733. * @param[in] lp low power enable flag
  734. *
  735. * @api
  736. */
  737. #define rccEnableTIM9(lp) rccEnableAPB2(RCC_APB2ENR_TIM9EN, lp)
  738. /**
  739. * @brief Disables the TIM9 peripheral clock.
  740. *
  741. * @api
  742. */
  743. #define rccDisableTIM9() rccDisableAPB2(RCC_APB2ENR_TIM9EN)
  744. /**
  745. * @brief Resets the TIM9 peripheral.
  746. *
  747. * @api
  748. */
  749. #define rccResetTIM9() rccResetAPB2(RCC_APB2RSTR_TIM9RST)
  750. /**
  751. * @brief Enables the TIM10 peripheral clock.
  752. * @note The @p lp parameter is ignored in this family.
  753. *
  754. * @param[in] lp low power enable flag
  755. *
  756. * @api
  757. */
  758. #define rccEnableTIM10(lp) rccEnableAPB2(RCC_APB2ENR_TIM10EN, lp)
  759. /**
  760. * @brief Disables the TIM10 peripheral clock.
  761. *
  762. * @api
  763. */
  764. #define rccDisableTIM10() rccDisableAPB2(RCC_APB2ENR_TIM10EN)
  765. /**
  766. * @brief Resets the TIM10 peripheral.
  767. *
  768. * @api
  769. */
  770. #define rccResetTIM10() rccResetAPB2(RCC_APB2RSTR_TIM10RST)
  771. /**
  772. * @brief Enables the TIM11 peripheral clock.
  773. * @note The @p lp parameter is ignored in this family.
  774. *
  775. * @param[in] lp low power enable flag
  776. *
  777. * @api
  778. */
  779. #define rccEnableTIM11(lp) rccEnableAPB2(RCC_APB2ENR_TIM11EN, lp)
  780. /**
  781. * @brief Disables the TIM11 peripheral clock.
  782. *
  783. * @api
  784. */
  785. #define rccDisableTIM11() rccDisableAPB2(RCC_APB2ENR_TIM11EN)
  786. /**
  787. * @brief Resets the TIM11 peripheral.
  788. *
  789. * @api
  790. */
  791. #define rccResetTIM11() rccResetAPB2(RCC_APB2RSTR_TIM11RST)
  792. /**
  793. * @brief Enables the TIM12 peripheral clock.
  794. * @note The @p lp parameter is ignored in this family.
  795. *
  796. * @param[in] lp low power enable flag
  797. *
  798. * @api
  799. */
  800. #define rccEnableTIM12(lp) rccEnableAPB1(RCC_APB1ENR_TIM12EN, lp)
  801. /**
  802. * @brief Disables the TIM12 peripheral clock.
  803. *
  804. * @api
  805. */
  806. #define rccDisableTIM12() rccDisableAPB1(RCC_APB1ENR_TIM12EN)
  807. /**
  808. * @brief Resets the TIM12 peripheral.
  809. *
  810. * @api
  811. */
  812. #define rccResetTIM12() rccResetAPB1(RCC_APB1RSTR_TIM12RST)
  813. /**
  814. * @brief Enables the TIM13 peripheral clock.
  815. * @note The @p lp parameter is ignored in this family.
  816. *
  817. * @param[in] lp low power enable flag
  818. *
  819. * @api
  820. */
  821. #define rccEnableTIM13(lp) rccEnableAPB1(RCC_APB1ENR_TIM13EN, lp)
  822. /**
  823. * @brief Disables the TIM13 peripheral clock.
  824. *
  825. * @api
  826. */
  827. #define rccDisableTIM13() rccDisableAPB1(RCC_APB1ENR_TIM13EN)
  828. /**
  829. * @brief Resets the TIM13 peripheral.
  830. *
  831. * @api
  832. */
  833. #define rccResetTIM13() rccResetAPB1(RCC_APB1RSTR_TIM13RST)
  834. /**
  835. * @brief Enables the TIM14 peripheral clock.
  836. * @note The @p lp parameter is ignored in this family.
  837. *
  838. * @param[in] lp low power enable flag
  839. *
  840. * @api
  841. */
  842. #define rccEnableTIM14(lp) rccEnableAPB1(RCC_APB1ENR_TIM14EN, lp)
  843. /**
  844. * @brief Disables the TIM14 peripheral clock.
  845. *
  846. * @api
  847. */
  848. #define rccDisableTIM14() rccDisableAPB1(RCC_APB1ENR_TIM14EN)
  849. /**
  850. * @brief Resets the TIM14 peripheral.
  851. *
  852. * @api
  853. */
  854. #define rccResetTIM14() rccResetAPB1(RCC_APB1RSTR_TIM14RST)
  855. /**
  856. * @brief Enables the TIM15 peripheral clock.
  857. * @note The @p lp parameter is ignored in this family.
  858. *
  859. * @param[in] lp low power enable flag
  860. *
  861. * @api
  862. */
  863. #define rccEnableTIM15(lp) rccEnableAPB2(RCC_APB2ENR_TIM15EN, lp)
  864. /**
  865. * @brief Disables the TIM15 peripheral clock.
  866. *
  867. * @api
  868. */
  869. #define rccDisableTIM15() rccDisableAPB2(RCC_APB2ENR_TIM15EN)
  870. /**
  871. * @brief Resets the TIM15 peripheral.
  872. *
  873. * @api
  874. */
  875. #define rccResetTIM15() rccResetAPB2(RCC_APB2RSTR_TIM15RST)
  876. /**
  877. * @brief Enables the TIM16 peripheral clock.
  878. * @note The @p lp parameter is ignored in this family.
  879. *
  880. * @param[in] lp low power enable flag
  881. *
  882. * @api
  883. */
  884. #define rccEnableTIM16(lp) rccEnableAPB2(RCC_APB2ENR_TIM16EN, lp)
  885. /**
  886. * @brief Disables the TIM16 peripheral clock.
  887. *
  888. * @api
  889. */
  890. #define rccDisableTIM16() rccDisableAPB2(RCC_APB2ENR_TIM16EN)
  891. /**
  892. * @brief Resets the TIM16 peripheral.
  893. *
  894. * @api
  895. */
  896. #define rccResetTIM16() rccResetAPB2(RCC_APB2RSTR_TIM16RST)
  897. /**
  898. * @brief Enables the TIM17 peripheral clock.
  899. * @note The @p lp parameter is ignored in this family.
  900. *
  901. * @param[in] lp low power enable flag
  902. *
  903. * @api
  904. */
  905. #define rccEnableTIM17(lp) rccEnableAPB2(RCC_APB2ENR_TIM17EN, lp)
  906. /**
  907. * @brief Disables the TIM17 peripheral clock.
  908. *
  909. * @api
  910. */
  911. #define rccDisableTIM17() rccDisableAPB2(RCC_APB2ENR_TIM17EN)
  912. /**
  913. * @brief Resets the TIM17 peripheral.
  914. *
  915. * @api
  916. */
  917. #define rccResetTIM17() rccResetAPB2(RCC_APB2RSTR_TIM17RST)
  918. /** @} */
  919. /**
  920. * @name USART/UART peripherals specific RCC operations
  921. * @{
  922. */
  923. /**
  924. * @brief Enables the USART1 peripheral clock.
  925. * @note The @p lp parameter is ignored in this family.
  926. *
  927. * @param[in] lp low power enable flag
  928. *
  929. * @api
  930. */
  931. #define rccEnableUSART1(lp) rccEnableAPB2(RCC_APB2ENR_USART1EN, lp)
  932. /**
  933. * @brief Disables the USART1 peripheral clock.
  934. *
  935. * @api
  936. */
  937. #define rccDisableUSART1() rccDisableAPB2(RCC_APB2ENR_USART1EN)
  938. /**
  939. * @brief Resets the USART1 peripheral.
  940. *
  941. * @api
  942. */
  943. #define rccResetUSART1() rccResetAPB2(RCC_APB2RSTR_USART1RST)
  944. /**
  945. * @brief Enables the USART2 peripheral clock.
  946. * @note The @p lp parameter is ignored in this family.
  947. *
  948. * @param[in] lp low power enable flag
  949. *
  950. * @api
  951. */
  952. #define rccEnableUSART2(lp) rccEnableAPB1(RCC_APB1ENR_USART2EN, lp)
  953. /**
  954. * @brief Disables the USART2 peripheral clock.
  955. *
  956. * @api
  957. */
  958. #define rccDisableUSART2() rccDisableAPB1(RCC_APB1ENR_USART2EN)
  959. /**
  960. * @brief Resets the USART2 peripheral.
  961. *
  962. * @api
  963. */
  964. #define rccResetUSART2() rccResetAPB1(RCC_APB1RSTR_USART2RST)
  965. /**
  966. * @brief Enables the USART3 peripheral clock.
  967. * @note The @p lp parameter is ignored in this family.
  968. *
  969. * @param[in] lp low power enable flag
  970. *
  971. * @api
  972. */
  973. #define rccEnableUSART3(lp) rccEnableAPB1(RCC_APB1ENR_USART3EN, lp)
  974. /**
  975. * @brief Disables the USART3 peripheral clock.
  976. *
  977. * @api
  978. */
  979. #define rccDisableUSART3() rccDisableAPB1(RCC_APB1ENR_USART3EN)
  980. /**
  981. * @brief Resets the USART3 peripheral.
  982. *
  983. * @api
  984. */
  985. #define rccResetUSART3() rccResetAPB1(RCC_APB1RSTR_USART3RST)
  986. /**
  987. * @brief Enables the UART4 peripheral clock.
  988. * @note The @p lp parameter is ignored in this family.
  989. *
  990. * @param[in] lp low power enable flag
  991. *
  992. * @api
  993. */
  994. #define rccEnableUART4(lp) rccEnableAPB1(RCC_APB1ENR_UART4EN, lp)
  995. /**
  996. * @brief Disables the UART4 peripheral clock.
  997. *
  998. * @api
  999. */
  1000. #define rccDisableUART4() rccDisableAPB1(RCC_APB1ENR_UART4EN)
  1001. /**
  1002. * @brief Resets the UART4 peripheral.
  1003. *
  1004. * @api
  1005. */
  1006. #define rccResetUART4() rccResetAPB1(RCC_APB1RSTR_UART4RST)
  1007. /**
  1008. * @brief Enables the UART5 peripheral clock.
  1009. * @note The @p lp parameter is ignored in this family.
  1010. *
  1011. * @param[in] lp low power enable flag
  1012. *
  1013. * @api
  1014. */
  1015. #define rccEnableUART5(lp) rccEnableAPB1(RCC_APB1ENR_UART5EN, lp)
  1016. /**
  1017. * @brief Disables the UART5 peripheral clock.
  1018. *
  1019. * @api
  1020. */
  1021. #define rccDisableUART5() rccDisableAPB1(RCC_APB1ENR_UART5EN)
  1022. /**
  1023. * @brief Resets the UART5 peripheral.
  1024. *
  1025. * @api
  1026. */
  1027. #define rccResetUART5() rccResetAPB1(RCC_APB1RSTR_UART5RST)
  1028. /** @} */
  1029. /**
  1030. * @name USB peripheral specific RCC operations
  1031. * @{
  1032. */
  1033. /**
  1034. * @brief Enables the USB peripheral clock.
  1035. * @note The @p lp parameter is ignored in this family.
  1036. *
  1037. * @param[in] lp low power enable flag
  1038. *
  1039. * @api
  1040. */
  1041. #define rccEnableUSB(lp) rccEnableAPB1(RCC_APB1ENR_USBEN, lp)
  1042. /**
  1043. * @brief Disables the USB peripheral clock
  1044. *
  1045. * @api
  1046. */
  1047. #define rccDisableUSB() rccDisableAPB1(RCC_APB1ENR_USBEN)
  1048. /**
  1049. * @brief Resets the USB peripheral.
  1050. *
  1051. * @api
  1052. */
  1053. #define rccResetUSB() rccResetAPB1(RCC_APB1RSTR_USBRST)
  1054. /** @} */
  1055. /**
  1056. * @name FSMC peripherals specific RCC operations
  1057. * @{
  1058. */
  1059. /**
  1060. * @brief Enables the FSMC peripheral clock.
  1061. *
  1062. * @param[in] lp low power enable flag
  1063. *
  1064. * @api
  1065. */
  1066. #define rccEnableFSMC(lp) rccEnableAHB(RCC_AHBENR_FSMCEN, lp)
  1067. /**
  1068. * @brief Disables the FSMC peripheral clock.
  1069. *
  1070. * @api
  1071. */
  1072. #define rccDisableFSMC() rccDisableAHB(RCC_AHBENR_FSMCEN)
  1073. /** @} */
  1074. /*===========================================================================*/
  1075. /* External declarations. */
  1076. /*===========================================================================*/
  1077. #ifdef __cplusplus
  1078. extern "C" {
  1079. #endif
  1080. #ifdef __cplusplus
  1081. }
  1082. #endif
  1083. #endif /* STM32_RCC_H */
  1084. /** @} */