1 /**
2   ******************************************************************************
3   * @file    stm32n6xx_hal_icache.h
4   * @author  MCD Application Team
5   * @brief   Header file of ICACHE HAL 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 
19 /* Define to prevent recursive inclusion ------------------------------------*/
20 #ifndef STM32N6xx_HAL_ICACHE_H
21 #define STM32N6xx_HAL_ICACHE_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes -----------------------------------------------------------------*/
28 #include "stm32n6xx_hal_def.h"
29 
30 #if defined(ICACHE)
31 /** @addtogroup STM32N6xx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup ICACHE
36   * @{
37   */
38 
39 /* Exported types -----------------------------------------------------------*/
40 
41 /* Exported constants -------------------------------------------------------*/
42 /** @defgroup ICACHE_Exported_Constants ICACHE Exported Constants
43   * @{
44   */
45 
46 /** @defgroup ICACHE_WaysSelection Ways selection
47   * @{
48   */
49 #define ICACHE_1WAY                    0U                /*!< 1-way cache (direct mapped cache) */
50 #define ICACHE_4WAYS                   ICACHE_CR_WAYSEL  /*!< 4-ways set associative cache (default) */
51 /**
52   * @}
53   */
54 
55 /** @defgroup ICACHE_Monitor_Type Monitor type
56   * @{
57   */
58 #define ICACHE_MONITOR_HIT_MISS        (ICACHE_CR_HITMEN | ICACHE_CR_MISSMEN) /*!< Hit & Miss monitoring */
59 #define ICACHE_MONITOR_HIT             ICACHE_CR_HITMEN                       /*!< Hit monitoring */
60 #define ICACHE_MONITOR_MISS            ICACHE_CR_MISSMEN                      /*!< Miss monitoring */
61 /**
62   * @}
63   */
64 
65 
66 /** @defgroup ICACHE_Interrupts Interrupts
67   * @{
68   */
69 #define ICACHE_IT_BUSYEND              ICACHE_IER_BSYENDIE /*!< Busy end interrupt */
70 #define ICACHE_IT_ERROR                ICACHE_IER_ERRIE    /*!< Cache error interrupt */
71 /**
72   * @}
73   */
74 
75 /** @defgroup ICACHE_Flags Flags
76   * @{
77   */
78 #define ICACHE_FLAG_BUSY               ICACHE_SR_BUSYF     /*!< Busy flag */
79 #define ICACHE_FLAG_BUSYEND            ICACHE_SR_BSYENDF   /*!< Busy end flag */
80 #define ICACHE_FLAG_ERROR              ICACHE_SR_ERRF      /*!< Cache error flag */
81 /**
82   * @}
83   */
84 
85 /**
86   * @}
87   */
88 
89 /* Exported macros ----------------------------------------------------------*/
90 /** @defgroup ICACHE_Exported_Macros ICACHE Exported Macros
91   * @{
92   */
93 
94 /** @defgroup ICACHE_Flags_Interrupts_Management Flags and Interrupts Management
95   * @brief macros to manage the specified ICACHE flags and interrupts.
96   * @{
97   */
98 
99 /** @brief  Enable ICACHE interrupts.
100   * @param  __INTERRUPT__ specifies the ICACHE interrupt sources to be enabled.
101   *         This parameter can be any combination of the following values:
102   *            @arg @ref ICACHE_IT_BUSYEND  Busy end interrupt
103   *            @arg @ref ICACHE_IT_ERROR  Cache error interrupt
104   */
105 #define __HAL_ICACHE_ENABLE_IT(__INTERRUPT__) SET_BIT(ICACHE->IER, (__INTERRUPT__))
106 
107 /** @brief  Disable ICACHE interrupts.
108   * @param  __INTERRUPT__ specifies the ICACHE interrupt sources to be disabled.
109   *         This parameter can be any combination of the following values:
110   *            @arg @ref ICACHE_IT_BUSYEND  Busy end interrupt
111   *            @arg @ref ICACHE_IT_ERROR  Cache error interrupt
112   */
113 #define __HAL_ICACHE_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(ICACHE->IER, (__INTERRUPT__))
114 
115 /** @brief  Check whether the specified ICACHE interrupt source is enabled or not.
116   * @param  __INTERRUPT__ specifies the ICACHE interrupt source to check.
117   *         This parameter can be any combination of the following values:
118   *            @arg @ref ICACHE_IT_BUSYEND  Busy end interrupt
119   *            @arg @ref ICACHE_IT_ERROR  Cache error interrupt
120   * @retval The state of __INTERRUPT__ (0 or 1).
121   */
122 #define __HAL_ICACHE_GET_IT_SOURCE(__INTERRUPT__)  \
123   ((READ_BIT(ICACHE->IER, (__INTERRUPT__)) == (__INTERRUPT__)) ? 1U : 0U)
124 
125 /** @brief  Check whether the selected ICACHE flag is set or not.
126   * @param  __FLAG__ specifies the flag to check.
127   *         This parameter can be one of the following values:
128   *            @arg @ref ICACHE_FLAG_BUSY  Busy flag
129   *            @arg @ref ICACHE_FLAG_BUSYEND  Busy end flag
130   *            @arg @ref ICACHE_FLAG_ERROR  Cache error flag
131   * @retval The state of __FLAG__ (0 or 1).
132   */
133 #define __HAL_ICACHE_GET_FLAG(__FLAG__) ((READ_BIT(ICACHE->SR, (__FLAG__)) != 0U) ? 1U : 0U)
134 
135 /** @brief  Clear the selected ICACHE flags.
136   * @param  __FLAG__ specifies the ICACHE flags to clear.
137   *         This parameter can be any combination of the following values:
138   *            @arg @ref ICACHE_FLAG_BUSYEND  Busy end flag
139   *            @arg @ref ICACHE_FLAG_ERROR  Cache error flag
140   */
141 #define __HAL_ICACHE_CLEAR_FLAG(__FLAG__) WRITE_REG(ICACHE->FCR, (__FLAG__))
142 
143 /**
144   * @}
145   */
146 
147 /**
148   * @}
149   */
150 
151 /* Exported functions -------------------------------------------------------*/
152 /** @addtogroup ICACHE_Exported_Functions
153   * @{
154   */
155 
156 /** @addtogroup ICACHE_Exported_Functions_Group1
157   * @brief    Initialization and control functions
158   * @{
159   */
160 /* Peripheral Control functions **********************************************/
161 HAL_StatusTypeDef HAL_ICACHE_Enable(void);
162 HAL_StatusTypeDef HAL_ICACHE_Disable(void);
163 uint32_t HAL_ICACHE_IsEnabled(void);
164 HAL_StatusTypeDef HAL_ICACHE_ConfigAssociativityMode(uint32_t AssociativityMode);
165 HAL_StatusTypeDef HAL_ICACHE_DeInit(void);
166 
167 /******* Invalidate in blocking mode (Polling) */
168 HAL_StatusTypeDef HAL_ICACHE_Invalidate(void);
169 /******* Invalidate in non-blocking mode (Interrupt) */
170 HAL_StatusTypeDef HAL_ICACHE_Invalidate_IT(void);
171 /******* Wait for Invalidate complete in blocking mode (Polling) */
172 HAL_StatusTypeDef HAL_ICACHE_WaitForInvalidateComplete(void);
173 
174 /******* Performance instruction cache monitoring functions */
175 HAL_StatusTypeDef HAL_ICACHE_Monitor_Start(uint32_t MonitorType);
176 HAL_StatusTypeDef HAL_ICACHE_Monitor_Stop(uint32_t MonitorType);
177 HAL_StatusTypeDef HAL_ICACHE_Monitor_Reset(uint32_t MonitorType);
178 uint32_t HAL_ICACHE_Monitor_GetHitValue(void);
179 uint32_t HAL_ICACHE_Monitor_GetMissValue(void);
180 
181 /**
182   * @}
183   */
184 
185 /** @addtogroup ICACHE_Exported_Functions_Group2
186   * @brief    IRQ and callback functions
187   * @{
188   */
189 /******* IRQHandler and Callbacks used in non-blocking mode (Interrupt) */
190 void HAL_ICACHE_IRQHandler(void);
191 void HAL_ICACHE_InvalidateCompleteCallback(void);
192 void HAL_ICACHE_ErrorCallback(void);
193 
194 /**
195   * @}
196   */
197 
198 
199 /**
200   * @}
201   */
202 
203 /**
204   * @}
205   */
206 
207 /**
208   * @}
209   */
210 #endif /* ICACHE */
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif /* STM32N6xx_HAL_ICACHE_H */
217