1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_hal_icache.h 4 * @author MCD Application Team 5 * @brief Header file of ICACHE HAL 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 19 /* Define to prevent recursive inclusion ------------------------------------*/ 20 #ifndef STM32L5xx_HAL_ICACHE_H 21 #define STM32L5xx_HAL_ICACHE_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes -----------------------------------------------------------------*/ 28 #include "stm32l5xx_hal_def.h" 29 30 /** @addtogroup STM32L5xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup ICACHE 35 * @{ 36 */ 37 38 /* Exported types -----------------------------------------------------------*/ 39 /** @defgroup ICACHE_Exported_Types ICACHE Exported Types 40 * @{ 41 */ 42 43 /** 44 * @brief HAL ICACHE region configuration structure definition 45 */ 46 typedef struct 47 { 48 uint32_t BaseAddress; /*!< Configures the Base address of Region i to be remapped */ 49 50 uint32_t RemapAddress; /*!< Configures the Remap address of Region i to be remapped */ 51 52 uint32_t Size; /*!< Configures the Region size. 53 This parameter can be a value of @ref ICACHE_Region_Size */ 54 55 uint32_t TrafficRoute; /*!< Selects the traffic route. 56 This parameter can be a value of @ref ICACHE_Traffic_Route */ 57 58 uint32_t OutputBurstType; /*!< Selects the output burst type. 59 This parameter can be a value of @ref ICACHE_Output_Burst_Type */ 60 } ICACHE_RegionConfigTypeDef; 61 /** 62 * @} 63 */ 64 65 /* Exported constants -------------------------------------------------------*/ 66 /** @defgroup ICACHE_Exported_Constants ICACHE Exported Constants 67 * @{ 68 */ 69 70 /** @defgroup ICACHE_WaysSelection Ways selection 71 * @{ 72 */ 73 #define ICACHE_1WAY 0U /*!< 1-way cache (direct mapped cache) */ 74 #define ICACHE_2WAYS ICACHE_CR_WAYSEL /*!< 2-ways set associative cache (default) */ 75 /** 76 * @} 77 */ 78 79 /** @defgroup ICACHE_Monitor_Type Monitor type 80 * @{ 81 */ 82 #define ICACHE_MONITOR_HIT_MISS (ICACHE_CR_HITMEN | ICACHE_CR_MISSMEN) /*!< Hit & Miss monitoring */ 83 #define ICACHE_MONITOR_HIT ICACHE_CR_HITMEN /*!< Hit monitoring */ 84 #define ICACHE_MONITOR_MISS ICACHE_CR_MISSMEN /*!< Miss monitoring */ 85 /** 86 * @} 87 */ 88 89 /** @defgroup ICACHE_Region Remapped Region number 90 * @{ 91 */ 92 #define ICACHE_REGION_0 0U /*!< Region 0 */ 93 #define ICACHE_REGION_1 1U /*!< Region 1 */ 94 #define ICACHE_REGION_2 2U /*!< Region 2 */ 95 #define ICACHE_REGION_3 3U /*!< Region 3 */ 96 /** 97 * @} 98 */ 99 100 /** @defgroup ICACHE_Region_Size Remapped Region size 101 * @{ 102 */ 103 #define ICACHE_REGIONSIZE_2MB 1U /*!< Region size 2MB */ 104 #define ICACHE_REGIONSIZE_4MB 2U /*!< Region size 4MB */ 105 #define ICACHE_REGIONSIZE_8MB 3U /*!< Region size 8MB */ 106 #define ICACHE_REGIONSIZE_16MB 4U /*!< Region size 16MB */ 107 #define ICACHE_REGIONSIZE_32MB 5U /*!< Region size 32MB */ 108 #define ICACHE_REGIONSIZE_64MB 6U /*!< Region size 64MB */ 109 #define ICACHE_REGIONSIZE_128MB 7U /*!< Region size 128MB */ 110 /** 111 * @} 112 */ 113 114 /** @defgroup ICACHE_Traffic_Route Remapped Traffic route 115 * @{ 116 */ 117 #define ICACHE_MASTER1_PORT 0U /*!< Master1 port */ 118 #define ICACHE_MASTER2_PORT ICACHE_CRRx_MSTSEL /*!< Master2 port */ 119 /** 120 * @} 121 */ 122 123 /** @defgroup ICACHE_Output_Burst_Type Remapped Output burst type 124 * @{ 125 */ 126 #define ICACHE_OUTPUT_BURST_WRAP 0U /*!< WRAP */ 127 #define ICACHE_OUTPUT_BURST_INCR ICACHE_CRRx_HBURST /*!< INCR */ 128 /** 129 * @} 130 */ 131 132 /** @defgroup ICACHE_Interrupts Interrupts 133 * @{ 134 */ 135 #define ICACHE_IT_BUSYEND ICACHE_IER_BSYENDIE /*!< Busy end interrupt */ 136 #define ICACHE_IT_ERROR ICACHE_IER_ERRIE /*!< Cache error interrupt */ 137 /** 138 * @} 139 */ 140 141 /** @defgroup ICACHE_Flags Flags 142 * @{ 143 */ 144 #define ICACHE_FLAG_BUSY ICACHE_SR_BUSYF /*!< Busy flag */ 145 #define ICACHE_FLAG_BUSYEND ICACHE_SR_BSYENDF /*!< Busy end flag */ 146 #define ICACHE_FLAG_ERROR ICACHE_SR_ERRF /*!< Cache error flag */ 147 /** 148 * @} 149 */ 150 151 /** 152 * @} 153 */ 154 155 /* Exported macros ----------------------------------------------------------*/ 156 /** @defgroup ICACHE_Exported_Macros ICACHE Exported Macros 157 * @{ 158 */ 159 160 /** @defgroup ICACHE_Flags_Interrupts_Management Flags and Interrupts Management 161 * @brief macros to manage the specified ICACHE flags and interrupts. 162 * @{ 163 */ 164 165 /** @brief Enable ICACHE interrupts. 166 * @param __INTERRUPT__ specifies the ICACHE interrupt sources to be enabled. 167 * This parameter can be any combination of the following values: 168 * @arg @ref ICACHE_IT_BUSYEND Busy end interrupt 169 * @arg @ref ICACHE_IT_ERROR Cache error interrupt 170 */ 171 #define __HAL_ICACHE_ENABLE_IT(__INTERRUPT__) SET_BIT(ICACHE->IER, (__INTERRUPT__)) 172 173 /** @brief Disable ICACHE interrupts. 174 * @param __INTERRUPT__ specifies the ICACHE interrupt sources to be disabled. 175 * This parameter can be any combination of the following values: 176 * @arg @ref ICACHE_IT_BUSYEND Busy end interrupt 177 * @arg @ref ICACHE_IT_ERROR Cache error interrupt 178 */ 179 #define __HAL_ICACHE_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(ICACHE->IER, (__INTERRUPT__)) 180 181 /** @brief Check whether the specified ICACHE interrupt source is enabled or not. 182 * @param __INTERRUPT__ specifies the ICACHE interrupt source to check. 183 * This parameter can be any combination of the following values: 184 * @arg @ref ICACHE_IT_BUSYEND Busy end interrupt 185 * @arg @ref ICACHE_IT_ERROR Cache error interrupt 186 * @retval The state of __INTERRUPT__ (0 or 1). 187 */ 188 #define __HAL_ICACHE_GET_IT_SOURCE(__INTERRUPT__) \ 189 ((READ_BIT(ICACHE->IER, (__INTERRUPT__)) == (__INTERRUPT__)) ? 1U : 0U) 190 191 /** @brief Check whether the selected ICACHE flag is set or not. 192 * @param __FLAG__ specifies the flag to check. 193 * This parameter can be one of the following values: 194 * @arg @ref ICACHE_FLAG_BUSY Busy flag 195 * @arg @ref ICACHE_FLAG_BUSYEND Busy end flag 196 * @arg @ref ICACHE_FLAG_ERROR Cache error flag 197 * @retval The state of __FLAG__ (0 or 1). 198 */ 199 #define __HAL_ICACHE_GET_FLAG(__FLAG__) ((READ_BIT(ICACHE->SR, (__FLAG__)) != 0U) ? 1U : 0U) 200 201 /** @brief Clear the selected ICACHE flags. 202 * @param __FLAG__ specifies the ICACHE flags to clear. 203 * This parameter can be any combination of the following values: 204 * @arg @ref ICACHE_FLAG_BUSYEND Busy end flag 205 * @arg @ref ICACHE_FLAG_ERROR Cache error flag 206 */ 207 #define __HAL_ICACHE_CLEAR_FLAG(__FLAG__) WRITE_REG(ICACHE->FCR, (__FLAG__)) 208 209 /** 210 * @} 211 */ 212 213 /** 214 * @} 215 */ 216 217 /* Exported functions -------------------------------------------------------*/ 218 /** @addtogroup ICACHE_Exported_Functions 219 * @{ 220 */ 221 222 /** @addtogroup ICACHE_Exported_Functions_Group1 223 * @brief Initialization and control functions 224 * @{ 225 */ 226 /* Peripheral Control functions **********************************************/ 227 HAL_StatusTypeDef HAL_ICACHE_Enable(void); 228 HAL_StatusTypeDef HAL_ICACHE_Disable(void); 229 uint32_t HAL_ICACHE_IsEnabled(void); 230 HAL_StatusTypeDef HAL_ICACHE_ConfigAssociativityMode(uint32_t AssociativityMode); 231 HAL_StatusTypeDef HAL_ICACHE_DeInit(void); 232 233 /******* Invalidate in blocking mode (Polling) */ 234 HAL_StatusTypeDef HAL_ICACHE_Invalidate(void); 235 /******* Invalidate in non-blocking mode (Interrupt) */ 236 HAL_StatusTypeDef HAL_ICACHE_Invalidate_IT(void); 237 /******* Wait for Invalidate complete in blocking mode (Polling) */ 238 HAL_StatusTypeDef HAL_ICACHE_WaitForInvalidateComplete(void); 239 240 /******* Performance instruction cache monitoring functions */ 241 HAL_StatusTypeDef HAL_ICACHE_Monitor_Start(uint32_t MonitorType); 242 HAL_StatusTypeDef HAL_ICACHE_Monitor_Stop(uint32_t MonitorType); 243 HAL_StatusTypeDef HAL_ICACHE_Monitor_Reset(uint32_t MonitorType); 244 uint32_t HAL_ICACHE_Monitor_GetHitValue(void); 245 uint32_t HAL_ICACHE_Monitor_GetMissValue(void); 246 247 /** 248 * @} 249 */ 250 251 /** @addtogroup ICACHE_Exported_Functions_Group2 252 * @brief IRQ and callback functions 253 * @{ 254 */ 255 /******* IRQHandler and Callbacks used in non-blocking mode (Interrupt) */ 256 void HAL_ICACHE_IRQHandler(void); 257 void HAL_ICACHE_InvalidateCompleteCallback(void); 258 void HAL_ICACHE_ErrorCallback(void); 259 260 /** 261 * @} 262 */ 263 264 /** @addtogroup ICACHE_Exported_Functions_Group3 265 * @brief Memory remapped regions functions 266 * @{ 267 */ 268 /******* Memory remapped regions functions */ 269 HAL_StatusTypeDef HAL_ICACHE_EnableRemapRegion(uint32_t Region, const ICACHE_RegionConfigTypeDef *const pRegionConfig); 270 HAL_StatusTypeDef HAL_ICACHE_DisableRemapRegion(uint32_t Region); 271 272 /** 273 * @} 274 */ 275 276 /** 277 * @} 278 */ 279 280 /** 281 * @} 282 */ 283 284 /** 285 * @} 286 */ 287 288 #ifdef __cplusplus 289 } 290 #endif 291 292 #endif /* STM32L5xx_HAL_ICACHE_H */ 293