stm32l5xx_hal_icache.h 9.6 KB

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