stm32l5xx_ll_icache.h 25 KB

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