stm32h5xx_hal_icache.h 9.5 KB

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