You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

454 lines
17 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_gfxmmu.h
  4. * @author MCD Application Team
  5. * @brief Header file of GFXMMU HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_GFXMMU_H
  21. #define STM32H7xx_HAL_GFXMMU_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. #if defined(GFXMMU)
  28. /** @addtogroup STM32H7xx_HAL_Driver
  29. * @{
  30. */
  31. /** @addtogroup GFXMMU
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup GFXMMU_Exported_Types GFXMMU Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief HAL GFXMMU states definition
  40. */
  41. typedef enum
  42. {
  43. HAL_GFXMMU_STATE_RESET = 0x00U, /*!< GFXMMU not initialized */
  44. HAL_GFXMMU_STATE_READY = 0x01U, /*!< GFXMMU initialized and ready for use */
  45. }HAL_GFXMMU_StateTypeDef;
  46. /**
  47. * @brief GFXMMU buffers structure definition
  48. */
  49. typedef struct
  50. {
  51. uint32_t Buf0Address; /*!< Physical address of buffer 0. */
  52. uint32_t Buf1Address; /*!< Physical address of buffer 1. */
  53. uint32_t Buf2Address; /*!< Physical address of buffer 2. */
  54. uint32_t Buf3Address; /*!< Physical address of buffer 3. */
  55. }GFXMMU_BuffersTypeDef;
  56. /**
  57. * @brief GFXMMU cache and pre-fetch structure definition
  58. */
  59. typedef struct
  60. {
  61. FunctionalState Activation; /*!< Cache and pre-fetch enable/disable.
  62. @note: All following parameters are usefull only if cache and pre-fetch are enabled. */
  63. uint32_t CacheLock; /*!< Locking the cache to a buffer.
  64. This parameter can be a value of @ref GFXMMU_CacheLock. */
  65. uint32_t CacheLockBuffer; /*!< Buffer on which the cache is locked.
  66. This parameter can be a value of @ref GFXMMU_CacheLockBuffer.
  67. @note: Usefull only when lock of the cache is enabled. */
  68. uint32_t CacheForce; /*!< Forcing the cache regardless MPU attributes.
  69. This parameter can be a value of @ref GFXMMU_CacheForce.
  70. @note: Usefull only when lock of the cache is enabled. */
  71. uint32_t OutterBufferability; /*!< Bufferability of an access generated by the GFXMMU cache.
  72. This parameter can be a value of @ref GFXMMU_OutterBufferability. */
  73. uint32_t OutterCachability; /*!< Cachability of an access generated by the GFXMMU cache.
  74. This parameter can be a value of @ref GFXMMU_OutterCachability. */
  75. uint32_t Prefetch; /*!< Pre-fetch enable/disable.
  76. This parameter can be a value of @ref GFXMMU_Prefetch. */
  77. }GFXMMU_CachePrefetchTypeDef;
  78. /**
  79. * @brief GFXMMU interrupts structure definition
  80. */
  81. typedef struct
  82. {
  83. FunctionalState Activation; /*!< Interrupts enable/disable */
  84. uint32_t UsedInterrupts; /*!< Interrupts used.
  85. This parameter can be a values combination of @ref GFXMMU_Interrupts.
  86. @note: Usefull only when interrupts are enabled. */
  87. }GFXMMU_InterruptsTypeDef;
  88. /**
  89. * @brief GFXMMU init structure definition
  90. */
  91. typedef struct
  92. {
  93. uint32_t BlocksPerLine; /*!< Number of blocks of 16 bytes per line.
  94. This parameter can be a value of @ref GFXMMU_BlocksPerLine. */
  95. uint32_t DefaultValue; /*!< Value returned when virtual memory location not physically mapped. */
  96. GFXMMU_BuffersTypeDef Buffers; /*!< Physical buffers addresses. */
  97. GFXMMU_CachePrefetchTypeDef CachePrefetch; /*!< Cache and pre-fetch parameters. */
  98. GFXMMU_InterruptsTypeDef Interrupts; /*!< Interrupts parameters. */
  99. }GFXMMU_InitTypeDef;
  100. /**
  101. * @brief GFXMMU handle structure definition
  102. */
  103. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  104. typedef struct __GFXMMU_HandleTypeDef
  105. #else
  106. typedef struct
  107. #endif
  108. {
  109. GFXMMU_TypeDef *Instance; /*!< GFXMMU instance */
  110. GFXMMU_InitTypeDef Init; /*!< GFXMMU init parameters */
  111. HAL_GFXMMU_StateTypeDef State; /*!< GFXMMU state */
  112. __IO uint32_t ErrorCode; /*!< GFXMMU error code */
  113. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  114. void (*ErrorCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU error callback */
  115. void (*MspInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP init callback */
  116. void (*MspDeInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP de-init callback */
  117. #endif
  118. }GFXMMU_HandleTypeDef;
  119. /**
  120. * @brief GFXMMU LUT line structure definition
  121. */
  122. typedef struct
  123. {
  124. uint32_t LineNumber; /*!< LUT line number.
  125. This parameter must be a number between Min_Data = 0 and Max_Data = 1023. */
  126. uint32_t LineStatus; /*!< LUT line enable/disable.
  127. This parameter can be a value of @ref GFXMMU_LutLineStatus. */
  128. uint32_t FirstVisibleBlock; /*!< First visible block on this line.
  129. This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
  130. uint32_t LastVisibleBlock; /*!< Last visible block on this line.
  131. This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
  132. int32_t LineOffset; /*!< Offset of block 0 of the current line in physical buffer.
  133. This parameter must be a number between Min_Data = -4080 and Max_Data = 4190208.
  134. @note: Line offset has to be computed with the following formula:
  135. LineOffset = [(Blocks already used) - (1st visible block)]*BlockSize. */
  136. }GFXMMU_LutLineTypeDef;
  137. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  138. /**
  139. * @brief GFXMMU callback ID enumeration definition
  140. */
  141. typedef enum
  142. {
  143. HAL_GFXMMU_ERROR_CB_ID = 0x00U, /*!< GFXMMU error callback ID */
  144. HAL_GFXMMU_MSPINIT_CB_ID = 0x01U, /*!< GFXMMU MSP init callback ID */
  145. HAL_GFXMMU_MSPDEINIT_CB_ID = 0x02U /*!< GFXMMU MSP de-init callback ID */
  146. }HAL_GFXMMU_CallbackIDTypeDef;
  147. /**
  148. * @brief GFXMMU callback pointer definition
  149. */
  150. typedef void (*pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu);
  151. #endif
  152. /**
  153. * @}
  154. */
  155. /* End of exported types -----------------------------------------------------*/
  156. /* Exported constants --------------------------------------------------------*/
  157. /** @defgroup GFXMMU_Exported_Constants GFXMMU Exported Constants
  158. * @{
  159. */
  160. /** @defgroup GFXMMU_BlocksPerLine GFXMMU blocks per line
  161. * @{
  162. */
  163. #define GFXMMU_256BLOCKS 0x00000000U /*!< 256 blocks of 16 bytes per line */
  164. #define GFXMMU_192BLOCKS GFXMMU_CR_192BM /*!< 192 blocks of 16 bytes per line */
  165. /**
  166. * @}
  167. */
  168. /** @defgroup GFXMMU_CacheLock GFXMMU cache lock
  169. * @{
  170. */
  171. #define GFXMMU_CACHE_LOCK_DISABLE 0x00000000U /*!< Cache not locked to a buffer */
  172. #define GFXMMU_CACHE_LOCK_ENABLE GFXMMU_CR_CL /*!< Cache locked to a buffer */
  173. /**
  174. * @}
  175. */
  176. /** @defgroup GFXMMU_CacheLockBuffer GFXMMU cache lock buffer
  177. * @{
  178. */
  179. #define GFXMMU_CACHE_LOCK_BUFFER0 0x00000000U /*!< Cache locked to buffer 0 */
  180. #define GFXMMU_CACHE_LOCK_BUFFER1 GFXMMU_CR_CLB_0 /*!< Cache locked to buffer 1 */
  181. #define GFXMMU_CACHE_LOCK_BUFFER2 GFXMMU_CR_CLB_1 /*!< Cache locked to buffer 2 */
  182. #define GFXMMU_CACHE_LOCK_BUFFER3 GFXMMU_CR_CLB /*!< Cache locked to buffer 3 */
  183. /**
  184. * @}
  185. */
  186. /** @defgroup GFXMMU_CacheForce GFXMMU cache force
  187. * @{
  188. */
  189. #define GFXMMU_CACHE_FORCE_DISABLE 0x00000000U /*!< Caching not forced */
  190. #define GFXMMU_CACHE_FORCE_ENABLE GFXMMU_CR_FC /*!< Caching forced */
  191. /**
  192. * @}
  193. */
  194. /** @defgroup GFXMMU_OutterBufferability GFXMMU outter bufferability
  195. * @{
  196. */
  197. #define GFXMMU_OUTTER_BUFFERABILITY_DISABLE 0x00000000U /*!< No bufferable */
  198. #define GFXMMU_OUTTER_BUFFERABILITY_ENABLE GFXMMU_CR_OB /*!< Bufferable */
  199. /**
  200. * @}
  201. */
  202. /** @defgroup GFXMMU_OutterCachability GFXMMU outter cachability
  203. * @{
  204. */
  205. #define GFXMMU_OUTTER_CACHABILITY_DISABLE 0x00000000U /*!< No cachable */
  206. #define GFXMMU_OUTTER_CACHABILITY_ENABLE GFXMMU_CR_OC /*!< Cachable */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup GFXMMU_Prefetch GFXMMU pre-fetch
  211. * @{
  212. */
  213. #define GFXMMU_PREFETCH_DISABLE GFXMMU_CR_PD /*!< Pre-fetch disable */
  214. #define GFXMMU_PREFETCH_ENABLE 0x00000000U /*!< Pre-fetch enable */
  215. /**
  216. * @}
  217. */
  218. /** @defgroup GFXMMU_Interrupts GFXMMU interrupts
  219. * @{
  220. */
  221. #define GFXMMU_AHB_MASTER_ERROR_IT GFXMMU_CR_AMEIE /*!< AHB master error interrupt */
  222. #define GFXMMU_BUFFER0_OVERFLOW_IT GFXMMU_CR_B0OIE /*!< Buffer 0 overflow interrupt */
  223. #define GFXMMU_BUFFER1_OVERFLOW_IT GFXMMU_CR_B1OIE /*!< Buffer 1 overflow interrupt */
  224. #define GFXMMU_BUFFER2_OVERFLOW_IT GFXMMU_CR_B2OIE /*!< Buffer 2 overflow interrupt */
  225. #define GFXMMU_BUFFER3_OVERFLOW_IT GFXMMU_CR_B3OIE /*!< Buffer 3 overflow interrupt */
  226. /**
  227. * @}
  228. */
  229. /** @defgroup GFXMMU_Error_Code GFXMMU Error Code
  230. * @{
  231. */
  232. #define GFXMMU_ERROR_NONE 0x00000000U /*!< No error */
  233. #define GFXMMU_ERROR_BUFFER0_OVERFLOW GFXMMU_SR_B0OF /*!< Buffer 0 overflow */
  234. #define GFXMMU_ERROR_BUFFER1_OVERFLOW GFXMMU_SR_B1OF /*!< Buffer 1 overflow */
  235. #define GFXMMU_ERROR_BUFFER2_OVERFLOW GFXMMU_SR_B2OF /*!< Buffer 2 overflow */
  236. #define GFXMMU_ERROR_BUFFER3_OVERFLOW GFXMMU_SR_B3OF /*!< Buffer 3 overflow */
  237. #define GFXMMU_ERROR_AHB_MASTER GFXMMU_SR_AMEF /*!< AHB master error */
  238. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  239. #define GFXMMU_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid callback error */
  240. #endif
  241. /**
  242. * @}
  243. */
  244. /** @defgroup GFXMMU_LutLineStatus GFXMMU LUT line status
  245. * @{
  246. */
  247. #define GFXMMU_LUT_LINE_DISABLE 0x00000000U /*!< LUT line disabled */
  248. #define GFXMMU_LUT_LINE_ENABLE GFXMMU_LUTxL_EN /*!< LUT line enabled */
  249. /**
  250. * @}
  251. */
  252. /** @defgroup GFXMMU_CacheForceParam GFXMMU cache force parameter
  253. * @{
  254. */
  255. #define GFXMMU_CACHE_FORCE_FLUSH GFXMMU_CCR_FF /*!< Force cache flush */
  256. #define GFXMMU_CACHE_FORCE_INVALIDATE GFXMMU_CCR_FI /*!< Force cache invalidate */
  257. /**
  258. * @}
  259. */
  260. /**
  261. * @}
  262. */
  263. /* End of exported constants -------------------------------------------------*/
  264. /* Exported macros -----------------------------------------------------------*/
  265. /** @defgroup GFXMMU_Exported_Macros GFXMMU Exported Macros
  266. * @{
  267. */
  268. /** @brief Reset GFXMMU handle state.
  269. * @param __HANDLE__ GFXMMU handle.
  270. * @retval None
  271. */
  272. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  273. #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) do{ \
  274. (__HANDLE__)->State = HAL_GFXMMU_STATE_RESET; \
  275. (__HANDLE__)->MspInitCallback = NULL; \
  276. (__HANDLE__)->MspDeInitCallback = NULL; \
  277. } while(0)
  278. #else
  279. #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_GFXMMU_STATE_RESET)
  280. #endif
  281. /**
  282. * @}
  283. */
  284. /* End of exported macros ----------------------------------------------------*/
  285. /* Exported functions --------------------------------------------------------*/
  286. /** @addtogroup GFXMMU_Exported_Functions GFXMMU Exported Functions
  287. * @{
  288. */
  289. /** @addtogroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions
  290. * @{
  291. */
  292. /* Initialization and de-initialization functions *****************************/
  293. HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu);
  294. HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu);
  295. void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu);
  296. void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu);
  297. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  298. /* GFXMMU callbacks register/unregister functions *****************************/
  299. HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu,
  300. HAL_GFXMMU_CallbackIDTypeDef CallbackID,
  301. pGFXMMU_CallbackTypeDef pCallback);
  302. HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu,
  303. HAL_GFXMMU_CallbackIDTypeDef CallbackID);
  304. #endif
  305. /**
  306. * @}
  307. */
  308. /** @addtogroup GFXMMU_Exported_Functions_Group2 Operations functions
  309. * @{
  310. */
  311. /* Operation functions ********************************************************/
  312. HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
  313. uint32_t FirstLine,
  314. uint32_t LinesNumber,
  315. uint32_t Address);
  316. HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
  317. uint32_t FirstLine,
  318. uint32_t LinesNumber);
  319. HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine);
  320. HAL_StatusTypeDef HAL_GFXMMU_ConfigForceCache(GFXMMU_HandleTypeDef *hgfxmmu, uint32_t ForceParam);
  321. HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers);
  322. HAL_StatusTypeDef HAL_GFXMMU_ModifyCachePrefetch(GFXMMU_HandleTypeDef *hgfxmmu,
  323. GFXMMU_CachePrefetchTypeDef *CachePrefetch);
  324. void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu);
  325. void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu);
  326. /**
  327. * @}
  328. */
  329. /** @defgroup GFXMMU_Exported_Functions_Group3 State functions
  330. * @{
  331. */
  332. /* State function *************************************************************/
  333. HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu);
  334. uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu);
  335. /**
  336. * @}
  337. */
  338. /**
  339. * @}
  340. */
  341. /* End of exported functions -------------------------------------------------*/
  342. /* Private macros ------------------------------------------------------------*/
  343. /** @defgroup GFXMMU_Private_Macros GFXMMU Private Macros
  344. * @{
  345. */
  346. #define IS_GFXMMU_BLOCKS_PER_LINE(VALUE) (((VALUE) == GFXMMU_256BLOCKS) || \
  347. ((VALUE) == GFXMMU_192BLOCKS))
  348. #define IS_GFXMMU_BUFFER_ADDRESS(VALUE) (((VALUE) & 0xFU) == 0U)
  349. #define IS_GFXMMU_CACHE_LOCK(VALUE) (((VALUE) == GFXMMU_CACHE_LOCK_DISABLE) || \
  350. ((VALUE) == GFXMMU_CACHE_LOCK_ENABLE))
  351. #define IS_GFXMMU_CACHE_LOCK_BUFFER(VALUE) (((VALUE) == GFXMMU_CACHE_LOCK_BUFFER0) || \
  352. ((VALUE) == GFXMMU_CACHE_LOCK_BUFFER1) || \
  353. ((VALUE) == GFXMMU_CACHE_LOCK_BUFFER2) || \
  354. ((VALUE) == GFXMMU_CACHE_LOCK_BUFFER3))
  355. #define IS_GFXMMU_CACHE_FORCE(VALUE) (((VALUE) == GFXMMU_CACHE_FORCE_DISABLE) || \
  356. ((VALUE) == GFXMMU_CACHE_FORCE_ENABLE))
  357. #define IS_GFXMMU_OUTTER_BUFFERABILITY(VALUE) (((VALUE) == GFXMMU_OUTTER_BUFFERABILITY_DISABLE) || \
  358. ((VALUE) == GFXMMU_OUTTER_BUFFERABILITY_ENABLE))
  359. #define IS_GFXMMU_OUTTER_CACHABILITY(VALUE) (((VALUE) == GFXMMU_OUTTER_CACHABILITY_DISABLE) || \
  360. ((VALUE) == GFXMMU_OUTTER_CACHABILITY_ENABLE))
  361. #define IS_GFXMMU_PREFETCH(VALUE) (((VALUE) == GFXMMU_PREFETCH_DISABLE) || \
  362. ((VALUE) == GFXMMU_PREFETCH_ENABLE))
  363. #define IS_GFXMMU_INTERRUPTS(VALUE) (((VALUE) & 0x1FU) != 0U)
  364. #define IS_GFXMMU_LUT_LINE(VALUE) ((VALUE) < 1024U)
  365. #define IS_GFXMMU_LUT_LINES_NUMBER(VALUE) (((VALUE) > 0U) && ((VALUE) <= 1024U))
  366. #define IS_GFXMMU_LUT_LINE_STATUS(VALUE) (((VALUE) == GFXMMU_LUT_LINE_DISABLE) || \
  367. ((VALUE) == GFXMMU_LUT_LINE_ENABLE))
  368. #define IS_GFXMMU_LUT_BLOCK(VALUE) ((VALUE) < 256U)
  369. #define IS_GFXMMU_LUT_LINE_OFFSET(VALUE) (((VALUE) >= -4080) && ((VALUE) <= 4190208))
  370. #define IS_GFXMMU_CACHE_FORCE_ACTION(VALUE) (((VALUE) == GFXMMU_CACHE_FORCE_FLUSH) || \
  371. ((VALUE) == GFXMMU_CACHE_FORCE_INVALIDATE) || \
  372. ((VALUE) == (GFXMMU_CACHE_FORCE_FLUSH | GFXMMU_CACHE_FORCE_INVALIDATE)))
  373. /**
  374. * @}
  375. */
  376. /* End of private macros -----------------------------------------------------*/
  377. /**
  378. * @}
  379. */
  380. /**
  381. * @}
  382. */
  383. #endif /* GFXMMU */
  384. #ifdef __cplusplus
  385. }
  386. #endif
  387. #endif /* STM32H7xx_HAL_GFXMMU_H */
  388. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/