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