stm32h5xx_ll_icache.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx_ll_icache.h
  4. * @author MCD Application Team
  5. * @brief Header file of ICACHE LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion ------------------------------------*/
  19. #ifndef STM32H5xx_LL_ICACHE_H
  20. #define STM32H5xx_LL_ICACHE_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes -----------------------------------------------------------------*/
  25. #include "stm32h5xx.h"
  26. /** @addtogroup STM32H5xx_LL_Driver
  27. * @{
  28. */
  29. #if defined(ICACHE)
  30. /** @defgroup ICACHE_LL ICACHE
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /* Private macros ------------------------------------------------------------*/
  37. /* Exported types ------------------------------------------------------------*/
  38. #if defined(ICACHE_CRRx_REN)
  39. /** @defgroup ICACHE_LL_REGION_CONFIG ICACHE Exported Configuration structure
  40. * @{
  41. */
  42. /**
  43. * @brief LL ICACHE region configuration structure definition
  44. */
  45. typedef struct
  46. {
  47. uint32_t BaseAddress; /*!< Configures the C-AHB base address to be remapped */
  48. uint32_t RemapAddress; /*!< Configures the remap address to be remapped */
  49. uint32_t Size; /*!< Configures the region size.
  50. This parameter can be a value of @ref ICACHE_LL_EC_Region_Size */
  51. uint32_t TrafficRoute; /*!< Selects the traffic route.
  52. This parameter can be a value of @ref ICACHE_LL_EC_Traffic_Route */
  53. uint32_t OutputBurstType; /*!< Selects the output burst type.
  54. This parameter can be a value of @ref ICACHE_LL_EC_Output_Burst_Type */
  55. } LL_ICACHE_RegionTypeDef;
  56. /**
  57. * @}
  58. */
  59. #endif /* ICACHE_CRRx_REN */
  60. /* Exported constants -------------------------------------------------------*/
  61. /** @defgroup ICACHE_LL_Exported_Constants ICACHE Exported Constants
  62. * @{
  63. */
  64. /** @defgroup ICACHE_LL_EC_WaysSelection Ways selection
  65. * @{
  66. */
  67. #define LL_ICACHE_1WAY 0U /*!< 1-way cache (direct mapped cache) */
  68. #define LL_ICACHE_2WAYS ICACHE_CR_WAYSEL /*!< 2-ways set associative cache (default) */
  69. /**
  70. * @}
  71. */
  72. /** @defgroup ICACHE_LL_EC_Monitor_Type Monitor type
  73. * @{
  74. */
  75. #define LL_ICACHE_MONITOR_HIT ICACHE_CR_HITMEN /*!< Hit monitor counter */
  76. #define LL_ICACHE_MONITOR_MISS ICACHE_CR_MISSMEN /*!< Miss monitor counter */
  77. #define LL_ICACHE_MONITOR_ALL (ICACHE_CR_HITMEN | ICACHE_CR_MISSMEN) /*!< All monitors counters */
  78. /**
  79. * @}
  80. */
  81. /** @defgroup ICACHE_LL_EC_GET_FLAG Get Flags Defines
  82. * @brief Flags defines which can be used with LL_ICACHE_ReadReg function
  83. * @{
  84. */
  85. #define LL_ICACHE_SR_BUSYF ICACHE_SR_BUSYF /*!< Busy flag */
  86. #define LL_ICACHE_SR_BSYENDF ICACHE_SR_BSYENDF /*!< Busy end flag */
  87. #define LL_ICACHE_SR_ERRF ICACHE_SR_ERRF /*!< Cache error flag */
  88. /**
  89. * @}
  90. */
  91. /** @defgroup ICACHE_LL_EC_CLEAR_FLAG Clear Flags Defines
  92. * @brief Flags defines which can be used with LL_ICACHE_WriteReg function
  93. * @{
  94. */
  95. #define LL_ICACHE_FCR_CBSYENDF ICACHE_FCR_CBSYENDF /*!< Busy end flag */
  96. #define LL_ICACHE_FCR_CERRF ICACHE_FCR_CERRF /*!< Cache error flag */
  97. /**
  98. * @}
  99. */
  100. /** @defgroup ICACHE_LL_EC_IT IT Defines
  101. * @brief IT defines which can be used with LL_ICACHE_ReadReg and LL_ICACHE_WriteReg functions
  102. * @{
  103. */
  104. #define LL_ICACHE_IER_BSYENDIE ICACHE_IER_BSYENDIE /*!< Busy end interrupt */
  105. #define LL_ICACHE_IER_ERRIE ICACHE_IER_ERRIE /*!< Cache error interrupt */
  106. /**
  107. * @}
  108. */
  109. #if defined(ICACHE_CRRx_REN)
  110. /** @defgroup ICACHE_LL_EC_Region Remapped Region number
  111. * @{
  112. */
  113. #define LL_ICACHE_REGION_0 0U /*!< Region 0 */
  114. #define LL_ICACHE_REGION_1 1U /*!< Region 1 */
  115. #define LL_ICACHE_REGION_2 2U /*!< Region 2 */
  116. #define LL_ICACHE_REGION_3 3U /*!< Region 3 */
  117. /**
  118. * @}
  119. */
  120. /** @defgroup ICACHE_LL_EC_Region_Size Remapped Region size
  121. * @{
  122. */
  123. #define LL_ICACHE_REGIONSIZE_2MB 1U /*!< Region size 2MB */
  124. #define LL_ICACHE_REGIONSIZE_4MB 2U /*!< Region size 4MB */
  125. #define LL_ICACHE_REGIONSIZE_8MB 3U /*!< Region size 8MB */
  126. #define LL_ICACHE_REGIONSIZE_16MB 4U /*!< Region size 16MB */
  127. #define LL_ICACHE_REGIONSIZE_32MB 5U /*!< Region size 32MB */
  128. #define LL_ICACHE_REGIONSIZE_64MB 6U /*!< Region size 64MB */
  129. #define LL_ICACHE_REGIONSIZE_128MB 7U /*!< Region size 128MB */
  130. /**
  131. * @}
  132. */
  133. /** @defgroup ICACHE_LL_EC_Traffic_Route Remapped Traffic route
  134. * @{
  135. */
  136. #define LL_ICACHE_MASTER1_PORT 0U /*!< Master1 port */
  137. #define LL_ICACHE_MASTER2_PORT ICACHE_CRRx_MSTSEL /*!< Master2 port */
  138. /**
  139. * @}
  140. */
  141. /** @defgroup ICACHE_LL_EC_Output_Burst_Type Remapped Output burst type
  142. * @{
  143. */
  144. #define LL_ICACHE_OUTPUT_BURST_WRAP 0U /*!< WRAP */
  145. #define LL_ICACHE_OUTPUT_BURST_INCR ICACHE_CRRx_HBURST /*!< INCR */
  146. /**
  147. * @}
  148. */
  149. #endif /* ICACHE_CRRx_REN */
  150. /**
  151. * @}
  152. */
  153. /* Exported macros ----------------------------------------------------------*/
  154. /** @defgroup ICACHE_LL_Exported_Macros ICACHE Exported Macros
  155. * @{
  156. */
  157. /** @defgroup ICACHE_LL_EM_WRITE_READ Common write and read registers Macros
  158. * @{
  159. */
  160. /**
  161. * @brief Write a value in ICACHE register
  162. * @param __REG__ Register to be written
  163. * @param __VALUE__ Value to be written in the register
  164. * @retval None
  165. */
  166. #define LL_ICACHE_WriteReg(__REG__, __VALUE__) WRITE_REG(ICACHE->__REG__, (__VALUE__))
  167. /**
  168. * @brief Read a value in ICACHE register
  169. * @param __REG__ Register to be read
  170. * @retval Register value
  171. */
  172. #define LL_ICACHE_ReadReg(__REG__) READ_REG(ICACHE->__REG__)
  173. /**
  174. * @}
  175. */
  176. /**
  177. * @}
  178. */
  179. /* Exported functions --------------------------------------------------------*/
  180. /** @defgroup ICACHE_LL_Exported_Functions ICACHE Exported Functions
  181. * @{
  182. */
  183. /** @defgroup ICACHE_LL_EF_Configuration Configuration
  184. * @{
  185. */
  186. /**
  187. * @brief Enable the ICACHE.
  188. * @rmtoll CR EN LL_ICACHE_Enable
  189. * @retval None
  190. */
  191. __STATIC_INLINE void LL_ICACHE_Enable(void)
  192. {
  193. SET_BIT(ICACHE->CR, ICACHE_CR_EN);
  194. }
  195. /**
  196. * @brief Disable the ICACHE.
  197. * @rmtoll CR EN LL_ICACHE_Disable
  198. * @retval None
  199. */
  200. __STATIC_INLINE void LL_ICACHE_Disable(void)
  201. {
  202. CLEAR_BIT(ICACHE->CR, ICACHE_CR_EN);
  203. }
  204. /**
  205. * @brief Return if ICACHE is enabled or not.
  206. * @rmtoll CR EN LL_ICACHE_IsEnabled
  207. * @retval State of bit (1 or 0).
  208. */
  209. __STATIC_INLINE uint32_t LL_ICACHE_IsEnabled(void)
  210. {
  211. return ((READ_BIT(ICACHE->CR, ICACHE_CR_EN) == (ICACHE_CR_EN)) ? 1UL : 0UL);
  212. }
  213. /**
  214. * @brief Select the ICACHE operating mode.
  215. * @rmtoll CR WAYSEL LL_ICACHE_SetMode
  216. * @param Mode This parameter can be one of the following values:
  217. * @arg @ref LL_ICACHE_1WAY
  218. * @arg @ref LL_ICACHE_2WAYS
  219. * @retval None
  220. */
  221. __STATIC_INLINE void LL_ICACHE_SetMode(uint32_t Mode)
  222. {
  223. MODIFY_REG(ICACHE->CR, ICACHE_CR_WAYSEL, Mode);
  224. }
  225. /**
  226. * @brief Get the selected ICACHE operating mode.
  227. * @rmtoll CR WAYSEL LL_ICACHE_GetMode
  228. * @retval Returned value can be one of the following values:
  229. * @arg @ref LL_ICACHE_1WAY
  230. * @arg @ref LL_ICACHE_2WAYS
  231. */
  232. __STATIC_INLINE uint32_t LL_ICACHE_GetMode(void)
  233. {
  234. return (READ_BIT(ICACHE->CR, ICACHE_CR_WAYSEL));
  235. }
  236. /**
  237. * @brief Invalidate the ICACHE.
  238. * @note Until the BSYEND flag is set, the cache is bypassed.
  239. * @rmtoll CR CACHEINV LL_ICACHE_Invalidate
  240. * @retval None
  241. */
  242. __STATIC_INLINE void LL_ICACHE_Invalidate(void)
  243. {
  244. SET_BIT(ICACHE->CR, ICACHE_CR_CACHEINV);
  245. }
  246. /**
  247. * @}
  248. */
  249. /** @defgroup ICACHE_LL_EF_Monitors Monitors
  250. * @{
  251. */
  252. /**
  253. * @brief Enable the hit/miss monitor(s).
  254. * @rmtoll CR HITMEN LL_ICACHE_EnableMonitors
  255. * @rmtoll CR MISSMEN LL_ICACHE_EnableMonitors
  256. * @param Monitors This parameter can be one or a combination of the following values:
  257. * @arg @ref LL_ICACHE_MONITOR_HIT
  258. * @arg @ref LL_ICACHE_MONITOR_MISS
  259. * @arg @ref LL_ICACHE_MONITOR_ALL
  260. * @retval None
  261. */
  262. __STATIC_INLINE void LL_ICACHE_EnableMonitors(uint32_t Monitors)
  263. {
  264. SET_BIT(ICACHE->CR, Monitors);
  265. }
  266. /**
  267. * @brief Disable the hit/miss monitor(s).
  268. * @rmtoll CR HITMEN LL_ICACHE_DisableMonitors
  269. * @rmtoll CR MISSMEN LL_ICACHE_DisableMonitors
  270. * @param Monitors This parameter can be one or a combination of the following values:
  271. * @arg @ref LL_ICACHE_MONITOR_HIT
  272. * @arg @ref LL_ICACHE_MONITOR_MISS
  273. * @arg @ref LL_ICACHE_MONITOR_ALL
  274. * @retval None
  275. */
  276. __STATIC_INLINE void LL_ICACHE_DisableMonitors(uint32_t Monitors)
  277. {
  278. CLEAR_BIT(ICACHE->CR, Monitors);
  279. }
  280. /**
  281. * @brief Check if the monitor(s) is(are) enabled or disabled.
  282. * @rmtoll CR HITMEN LL_ICACHE_IsEnabledMonitors
  283. * @rmtoll CR MISSMEN LL_ICACHE_IsEnabledMonitors
  284. * @param Monitors This parameter can be one or a combination of the following values:
  285. * @arg @ref LL_ICACHE_MONITOR_HIT
  286. * @arg @ref LL_ICACHE_MONITOR_MISS
  287. * @arg @ref LL_ICACHE_MONITOR_ALL
  288. * @retval State of parameter value (1 or 0).
  289. */
  290. __STATIC_INLINE uint32_t LL_ICACHE_IsEnabledMonitors(uint32_t Monitors)
  291. {
  292. return ((READ_BIT(ICACHE->CR, Monitors) == (Monitors)) ? 1UL : 0UL);
  293. }
  294. /**
  295. * @brief Reset the hit/miss monitor(s).
  296. * @rmtoll CR HITMRST LL_ICACHE_ResetMonitors
  297. * @rmtoll CR MISSMRST LL_ICACHE_ResetMonitors
  298. * @param Monitors This parameter can be one or a combination of the following values:
  299. * @arg @ref LL_ICACHE_MONITOR_HIT
  300. * @arg @ref LL_ICACHE_MONITOR_MISS
  301. * @arg @ref LL_ICACHE_MONITOR_ALL
  302. * @retval None
  303. */
  304. __STATIC_INLINE void LL_ICACHE_ResetMonitors(uint32_t Monitors)
  305. {
  306. /* Reset */
  307. SET_BIT(ICACHE->CR, (Monitors << 2U));
  308. /* Release reset */
  309. CLEAR_BIT(ICACHE->CR, (Monitors << 2U));
  310. }
  311. /**
  312. * @brief Get the Hit monitor.
  313. * @note Upon reaching the 32-bit maximum value, hit monitor does not wrap.
  314. * @rmtoll HMONR HITMON LL_ICACHE_GetHitMonitor
  315. * @retval Value between Min_Data=0 and Max_Data=0xFFFFFFFF
  316. */
  317. __STATIC_INLINE uint32_t LL_ICACHE_GetHitMonitor(void)
  318. {
  319. return (ICACHE->HMONR);
  320. }
  321. /**
  322. * @brief Get the Miss monitor.
  323. * @note Upon reaching the 16-bit maximum value, miss monitor does not wrap.
  324. * @rmtoll MMONR MISSMON LL_ICACHE_GetMissMonitor
  325. * @retval Value between Min_Data=0 and Max_Data=0xFFFF
  326. */
  327. __STATIC_INLINE uint32_t LL_ICACHE_GetMissMonitor(void)
  328. {
  329. return (ICACHE->MMONR);
  330. }
  331. /**
  332. * @}
  333. */
  334. /** @defgroup ICACHE_LL_EF_IT_Management IT_Management
  335. * @{
  336. */
  337. /**
  338. * @brief Enable BSYEND interrupt.
  339. * @rmtoll IER BSYENDIE LL_ICACHE_EnableIT_BSYEND
  340. * @retval None
  341. */
  342. __STATIC_INLINE void LL_ICACHE_EnableIT_BSYEND(void)
  343. {
  344. SET_BIT(ICACHE->IER, ICACHE_IER_BSYENDIE);
  345. }
  346. /**
  347. * @brief Disable BSYEND interrupt.
  348. * @rmtoll IER BSYENDIE LL_ICACHE_DisableIT_BSYEND
  349. * @retval None
  350. */
  351. __STATIC_INLINE void LL_ICACHE_DisableIT_BSYEND(void)
  352. {
  353. CLEAR_BIT(ICACHE->IER, ICACHE_IER_BSYENDIE);
  354. }
  355. /**
  356. * @brief Check if the BSYEND Interrupt is enabled or disabled.
  357. * @rmtoll IER BSYENDIE LL_ICACHE_IsEnabledIT_BSYEND
  358. * @retval State of bit (1 or 0).
  359. */
  360. __STATIC_INLINE uint32_t LL_ICACHE_IsEnabledIT_BSYEND(void)
  361. {
  362. return ((READ_BIT(ICACHE->IER, ICACHE_IER_BSYENDIE) == (ICACHE_IER_BSYENDIE)) ? 1UL : 0UL);
  363. }
  364. /**
  365. * @brief Enable ERR interrupt.
  366. * @rmtoll IER ERRIE LL_ICACHE_EnableIT_ERR
  367. * @retval None
  368. */
  369. __STATIC_INLINE void LL_ICACHE_EnableIT_ERR(void)
  370. {
  371. SET_BIT(ICACHE->IER, ICACHE_IER_ERRIE);
  372. }
  373. /**
  374. * @brief Disable ERR interrupt.
  375. * @rmtoll IER ERRIE LL_ICACHE_DisableIT_ERR
  376. * @retval None
  377. */
  378. __STATIC_INLINE void LL_ICACHE_DisableIT_ERR(void)
  379. {
  380. CLEAR_BIT(ICACHE->IER, ICACHE_IER_ERRIE);
  381. }
  382. /**
  383. * @brief Check if the ERR Interrupt is enabled or disabled.
  384. * @rmtoll IER ERRIE LL_ICACHE_IsEnabledIT_ERR
  385. * @retval State of bit (1 or 0).
  386. */
  387. __STATIC_INLINE uint32_t LL_ICACHE_IsEnabledIT_ERR(void)
  388. {
  389. return ((READ_BIT(ICACHE->IER, ICACHE_IER_ERRIE) == (ICACHE_IER_ERRIE)) ? 1UL : 0UL);
  390. }
  391. /**
  392. * @}
  393. */
  394. /** @defgroup ICACHE_LL_EF_FLAG_Management FLAG_Management
  395. * @{
  396. */
  397. /**
  398. * @brief Indicate the status of an ongoing operation flag.
  399. * @rmtoll SR BUSYF LL_ICACHE_IsActiveFlag_BUSY
  400. * @retval State of bit (1 or 0).
  401. */
  402. __STATIC_INLINE uint32_t LL_ICACHE_IsActiveFlag_BUSY(void)
  403. {
  404. return ((READ_BIT(ICACHE->SR, ICACHE_SR_BUSYF) == (ICACHE_SR_BUSYF)) ? 1UL : 0UL);
  405. }
  406. /**
  407. * @brief Indicate the status of an operation end flag.
  408. * @rmtoll SR BSYEND LL_ICACHE_IsActiveFlag_BSYEND
  409. * @retval State of bit (1 or 0).
  410. */
  411. __STATIC_INLINE uint32_t LL_ICACHE_IsActiveFlag_BSYEND(void)
  412. {
  413. return ((READ_BIT(ICACHE->SR, ICACHE_SR_BSYENDF) == (ICACHE_SR_BSYENDF)) ? 1UL : 0UL);
  414. }
  415. /**
  416. * @brief Indicate the status of an error flag.
  417. * @rmtoll SR ERRF LL_ICACHE_IsActiveFlag_ERR
  418. * @retval State of bit (1 or 0).
  419. */
  420. __STATIC_INLINE uint32_t LL_ICACHE_IsActiveFlag_ERR(void)
  421. {
  422. return ((READ_BIT(ICACHE->SR, ICACHE_SR_ERRF) == (ICACHE_SR_ERRF)) ? 1UL : 0UL);
  423. }
  424. /**
  425. * @brief Clear busy end of operation flag.
  426. * @rmtoll FCR CBSYENDF LL_ICACHE_ClearFlag_BSYEND
  427. * @retval None
  428. */
  429. __STATIC_INLINE void LL_ICACHE_ClearFlag_BSYEND(void)
  430. {
  431. WRITE_REG(ICACHE->FCR, ICACHE_FCR_CBSYENDF);
  432. }
  433. /**
  434. * @brief Clear error flag.
  435. * @rmtoll FCR ERRF LL_ICACHE_ClearFlag_ERR
  436. * @retval None
  437. */
  438. __STATIC_INLINE void LL_ICACHE_ClearFlag_ERR(void)
  439. {
  440. WRITE_REG(ICACHE->FCR, ICACHE_FCR_CERRF);
  441. }
  442. /**
  443. * @}
  444. */
  445. #if defined(ICACHE_CRRx_REN)
  446. /** @defgroup ICACHE_LL_EF_REGION_Management REGION_Management
  447. * @{
  448. */
  449. /**
  450. * @brief Enable the remapped memory region.
  451. * @note The region must have been already configured.
  452. * @rmtoll CRRx REN LL_ICACHE_EnableRegion
  453. * @param Region This parameter can be one of the following values:
  454. * @arg @ref LL_ICACHE_REGION_0
  455. * @arg @ref LL_ICACHE_REGION_1
  456. * @arg @ref LL_ICACHE_REGION_2
  457. * @arg @ref LL_ICACHE_REGION_3
  458. * @retval None
  459. */
  460. __STATIC_INLINE void LL_ICACHE_EnableRegion(uint32_t Region)
  461. {
  462. SET_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  463. ICACHE_CRRx_REN);
  464. }
  465. /**
  466. * @brief Disable the remapped memory region.
  467. * @rmtoll CRRx REN LL_ICACHE_DisableRegion
  468. * @param Region This parameter can be one of the following values:
  469. * @arg @ref LL_ICACHE_REGION_0
  470. * @arg @ref LL_ICACHE_REGION_1
  471. * @arg @ref LL_ICACHE_REGION_2
  472. * @arg @ref LL_ICACHE_REGION_3
  473. * @retval None
  474. */
  475. __STATIC_INLINE void LL_ICACHE_DisableRegion(uint32_t Region)
  476. {
  477. CLEAR_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  478. ICACHE_CRRx_REN);
  479. }
  480. /**
  481. * @brief Return if remapped memory region is enabled or not.
  482. * @rmtoll CRRx REN LL_ICACHE_IsEnabledRegion
  483. * @param Region This parameter can be one of the following values:
  484. * @arg @ref LL_ICACHE_REGION_0
  485. * @arg @ref LL_ICACHE_REGION_1
  486. * @arg @ref LL_ICACHE_REGION_2
  487. * @arg @ref LL_ICACHE_REGION_3
  488. * @retval State of bit (1 or 0).
  489. */
  490. __STATIC_INLINE uint32_t LL_ICACHE_IsEnabledRegion(uint32_t Region)
  491. {
  492. return ((READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  493. ICACHE_CRRx_REN) == (ICACHE_CRRx_REN)) ? 1UL : 0UL);
  494. }
  495. /**
  496. * @brief Select the memory remapped region base address.
  497. * @note The useful bits depends on RSIZE as described in the Reference Manual.
  498. * @rmtoll CRRx BASEADDR LL_ICACHE_SetRegionBaseAddress
  499. * @param Region This parameter can be one of the following values:
  500. * @arg @ref LL_ICACHE_REGION_0
  501. * @arg @ref LL_ICACHE_REGION_1
  502. * @arg @ref LL_ICACHE_REGION_2
  503. * @arg @ref LL_ICACHE_REGION_3
  504. * @param Address Alias address in the Code region
  505. * @retval None
  506. */
  507. __STATIC_INLINE void LL_ICACHE_SetRegionBaseAddress(uint32_t Region, uint32_t Address)
  508. {
  509. MODIFY_REG(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  510. ICACHE_CRRx_BASEADDR, ((Address & 0x1FFFFFFFU) >> 21U));
  511. }
  512. /**
  513. * @brief Get the memory remapped region base address.
  514. * @note The base address is the alias in the Code region.
  515. * @note The useful bits depends on RSIZE as described in the Reference Manual.
  516. * @rmtoll CRRx BASEADDR LL_ICACHE_GetRegionBaseAddress
  517. * @param Region This parameter can be one of the following values:
  518. * @arg @ref LL_ICACHE_REGION_0
  519. * @arg @ref LL_ICACHE_REGION_1
  520. * @arg @ref LL_ICACHE_REGION_2
  521. * @arg @ref LL_ICACHE_REGION_3
  522. * @retval Address Alias address in the Code region
  523. */
  524. __STATIC_INLINE uint32_t LL_ICACHE_GetRegionBaseAddress(uint32_t Region)
  525. {
  526. return (READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  527. ICACHE_CRRx_BASEADDR) << 21U);
  528. }
  529. /**
  530. * @brief Select the memory remapped region address.
  531. * @note The useful bits depends on RSIZE as described in the Reference Manual.
  532. * @rmtoll CRRx REMAPADDR LL_ICACHE_SetRegionRemapAddress
  533. * @param Region This parameter can be one of the following values:
  534. * @arg @ref LL_ICACHE_REGION_0
  535. * @arg @ref LL_ICACHE_REGION_1
  536. * @arg @ref LL_ICACHE_REGION_2
  537. * @arg @ref LL_ICACHE_REGION_3
  538. * @param Address Memory address to remap
  539. * @retval None
  540. */
  541. __STATIC_INLINE void LL_ICACHE_SetRegionRemapAddress(uint32_t Region, uint32_t Address)
  542. {
  543. MODIFY_REG(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  544. ICACHE_CRRx_REMAPADDR, ((Address >> 21U) << ICACHE_CRRx_REMAPADDR_Pos));
  545. }
  546. /**
  547. * @brief Get the memory remapped region address.
  548. * @note The useful bits depends on RSIZE as described in the Reference Manual.
  549. * @rmtoll CRRx REMAPADDR LL_ICACHE_GetRegionRemapAddress
  550. * @param Region This parameter can be one of the following values:
  551. * @arg @ref LL_ICACHE_REGION_0
  552. * @arg @ref LL_ICACHE_REGION_1
  553. * @arg @ref LL_ICACHE_REGION_2
  554. * @arg @ref LL_ICACHE_REGION_3
  555. * @retval Address Remapped memory address
  556. */
  557. __STATIC_INLINE uint32_t LL_ICACHE_GetRegionRemapAddress(uint32_t Region)
  558. {
  559. return ((READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  560. ICACHE_CRRx_REMAPADDR) >> ICACHE_CRRx_REMAPADDR_Pos) << 21U);
  561. }
  562. /**
  563. * @brief Select the memory remapped region size.
  564. * @rmtoll CRRx RSIZE LL_ICACHE_SetRegionSize
  565. * @param Region This parameter can be one of the following values:
  566. * @arg @ref LL_ICACHE_REGION_0
  567. * @arg @ref LL_ICACHE_REGION_1
  568. * @arg @ref LL_ICACHE_REGION_2
  569. * @arg @ref LL_ICACHE_REGION_3
  570. * @param Size This parameter can be one of the following values:
  571. * @arg @ref LL_ICACHE_REGIONSIZE_2MB
  572. * @arg @ref LL_ICACHE_REGIONSIZE_4MB
  573. * @arg @ref LL_ICACHE_REGIONSIZE_8MB
  574. * @arg @ref LL_ICACHE_REGIONSIZE_16MB
  575. * @arg @ref LL_ICACHE_REGIONSIZE_32MB
  576. * @arg @ref LL_ICACHE_REGIONSIZE_64MB
  577. * @arg @ref LL_ICACHE_REGIONSIZE_128MB
  578. * @retval None
  579. */
  580. __STATIC_INLINE void LL_ICACHE_SetRegionSize(uint32_t Region, uint32_t Size)
  581. {
  582. MODIFY_REG(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  583. ICACHE_CRRx_RSIZE, (Size << ICACHE_CRRx_RSIZE_Pos));
  584. }
  585. /**
  586. * @brief Get the selected the memory remapped region size.
  587. * @rmtoll CRRx RSIZE LL_ICACHE_GetRegionSize
  588. * @param Region This parameter can be one of the following values:
  589. * @arg @ref LL_ICACHE_REGION_0
  590. * @arg @ref LL_ICACHE_REGION_1
  591. * @arg @ref LL_ICACHE_REGION_2
  592. * @arg @ref LL_ICACHE_REGION_3
  593. * @retval Returned value can be one of the following values:
  594. * @arg @ref LL_ICACHE_REGIONSIZE_2MB
  595. * @arg @ref LL_ICACHE_REGIONSIZE_4MB
  596. * @arg @ref LL_ICACHE_REGIONSIZE_8MB
  597. * @arg @ref LL_ICACHE_REGIONSIZE_16MB
  598. * @arg @ref LL_ICACHE_REGIONSIZE_32MB
  599. * @arg @ref LL_ICACHE_REGIONSIZE_64MB
  600. * @arg @ref LL_ICACHE_REGIONSIZE_128MB
  601. */
  602. __STATIC_INLINE uint32_t LL_ICACHE_GetRegionSize(uint32_t Region)
  603. {
  604. return (READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  605. ICACHE_CRRx_RSIZE) >> ICACHE_CRRx_RSIZE_Pos);
  606. }
  607. /**
  608. * @brief Select the memory remapped region output burst type.
  609. * @rmtoll CRRx HBURST LL_ICACHE_SetRegionOutputBurstType
  610. * @param Region This parameter can be one of the following values:
  611. * @arg @ref LL_ICACHE_REGION_0
  612. * @arg @ref LL_ICACHE_REGION_1
  613. * @arg @ref LL_ICACHE_REGION_2
  614. * @arg @ref LL_ICACHE_REGION_3
  615. * @param Type This parameter can be one of the following values:
  616. * @arg @ref LL_ICACHE_OUTPUT_BURST_WRAP
  617. * @arg @ref LL_ICACHE_OUTPUT_BURST_INCR
  618. * @retval None
  619. */
  620. __STATIC_INLINE void LL_ICACHE_SetRegionOutputBurstType(uint32_t Region, uint32_t Type)
  621. {
  622. MODIFY_REG(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  623. ICACHE_CRRx_HBURST, Type);
  624. }
  625. /**
  626. * @brief Get the selected the memory remapped region output burst type.
  627. * @rmtoll CRRx HBURST LL_ICACHE_GetRegionOutputBurstType
  628. * @param Region This parameter can be one of the following values:
  629. * @arg @ref LL_ICACHE_REGION_0
  630. * @arg @ref LL_ICACHE_REGION_1
  631. * @arg @ref LL_ICACHE_REGION_2
  632. * @arg @ref LL_ICACHE_REGION_3
  633. * @retval Returned value can be one of the following values:
  634. * @arg @ref LL_ICACHE_OUTPUT_BURST_WRAP
  635. * @arg @ref LL_ICACHE_OUTPUT_BURST_INCR
  636. */
  637. __STATIC_INLINE uint32_t LL_ICACHE_GetRegionOutputBurstType(uint32_t Region)
  638. {
  639. return (READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  640. ICACHE_CRRx_HBURST));
  641. }
  642. /**
  643. * @brief Select the memory remapped region cache master port.
  644. * @rmtoll CRRx MSTSEL LL_ICACHE_SetRegionMasterPort
  645. * @param Region This parameter can be one of the following values:
  646. * @arg @ref LL_ICACHE_REGION_0
  647. * @arg @ref LL_ICACHE_REGION_1
  648. * @arg @ref LL_ICACHE_REGION_2
  649. * @arg @ref LL_ICACHE_REGION_3
  650. * @param Port This parameter can be one of the following values:
  651. * @arg @ref LL_ICACHE_MASTER1_PORT
  652. * @arg @ref LL_ICACHE_MASTER2_PORT
  653. * @retval None
  654. */
  655. __STATIC_INLINE void LL_ICACHE_SetRegionMasterPort(uint32_t Region, uint32_t Port)
  656. {
  657. MODIFY_REG(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  658. ICACHE_CRRx_MSTSEL, Port);
  659. }
  660. /**
  661. * @brief Get the selected the memory remapped region cache master port.
  662. * @rmtoll CRRx MSTSEL LL_ICACHE_GetRegionMasterPort
  663. * @param Region This parameter can be one of the following values:
  664. * @arg @ref LL_ICACHE_REGION_0
  665. * @arg @ref LL_ICACHE_REGION_1
  666. * @arg @ref LL_ICACHE_REGION_2
  667. * @arg @ref LL_ICACHE_REGION_3
  668. * @retval Returned value can be one of the following values:
  669. * @arg @ref LL_ICACHE_MASTER1_PORT
  670. * @arg @ref LL_ICACHE_MASTER2_PORT
  671. */
  672. __STATIC_INLINE uint32_t LL_ICACHE_GetRegionMasterPort(uint32_t Region)
  673. {
  674. return (READ_BIT(*((__IO uint32_t *)(&(ICACHE->CRR0) + (1U * Region))), \
  675. ICACHE_CRRx_MSTSEL));
  676. }
  677. /**
  678. * @}
  679. */
  680. #if defined(USE_FULL_LL_DRIVER)
  681. /** @defgroup ICACHE_LL_EF_REGION_Init Region Initialization functions
  682. * @{
  683. */
  684. void LL_ICACHE_ConfigRegion(uint32_t Region, const LL_ICACHE_RegionTypeDef *const pICACHE_RegionStruct);
  685. /**
  686. * @}
  687. */
  688. #endif /* USE_FULL_LL_DRIVER */
  689. #endif /* ICACHE_CRRx_REN */
  690. /**
  691. * @}
  692. */
  693. /**
  694. * @}
  695. */
  696. #endif /* ICACHE */
  697. /**
  698. * @}
  699. */
  700. #ifdef __cplusplus
  701. }
  702. #endif
  703. #endif /* STM32H5xx_LL_ICACHE_H */