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