stm32_rcc.h 29 KB

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