stm32l4xx_hal_gfxmmu.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_gfxmmu.h
  4. * @author MCD Application Team
  5. * @brief Header file of GFXMMU HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 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 STM32L4xx_HAL_GFXMMU_H
  20. #define STM32L4xx_HAL_GFXMMU_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx_hal_def.h"
  26. #if defined(GFXMMU)
  27. /** @addtogroup STM32L4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup GFXMMU
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup GFXMMU_Exported_Types GFXMMU Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief HAL GFXMMU states definition
  39. */
  40. typedef enum
  41. {
  42. HAL_GFXMMU_STATE_RESET = 0x00U, /*!< GFXMMU not initialized */
  43. HAL_GFXMMU_STATE_READY = 0x01U, /*!< GFXMMU initialized and ready for use */
  44. }HAL_GFXMMU_StateTypeDef;
  45. /**
  46. * @brief GFXMMU buffers structure definition
  47. */
  48. typedef struct
  49. {
  50. uint32_t Buf0Address; /*!< Physical address of buffer 0. */
  51. uint32_t Buf1Address; /*!< Physical address of buffer 1. */
  52. uint32_t Buf2Address; /*!< Physical address of buffer 2. */
  53. uint32_t Buf3Address; /*!< Physical address of buffer 3. */
  54. }GFXMMU_BuffersTypeDef;
  55. /**
  56. * @brief GFXMMU interrupts structure definition
  57. */
  58. typedef struct
  59. {
  60. FunctionalState Activation; /*!< Interrupts enable/disable */
  61. uint32_t UsedInterrupts; /*!< Interrupts used.
  62. This parameter can be a values combination of @ref GFXMMU_Interrupts.
  63. @note: Useful only when interrupts are enabled. */
  64. }GFXMMU_InterruptsTypeDef;
  65. /**
  66. * @brief GFXMMU init structure definition
  67. */
  68. typedef struct
  69. {
  70. uint32_t BlocksPerLine; /*!< Number of blocks of 16 bytes per line.
  71. This parameter can be a value of @ref GFXMMU_BlocksPerLine. */
  72. uint32_t DefaultValue; /*!< Value returned when virtual memory location not physically mapped. */
  73. GFXMMU_BuffersTypeDef Buffers; /*!< Physical buffers addresses. */
  74. GFXMMU_InterruptsTypeDef Interrupts; /*!< Interrupts parameters. */
  75. }GFXMMU_InitTypeDef;
  76. /**
  77. * @brief GFXMMU handle structure definition
  78. */
  79. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  80. typedef struct __GFXMMU_HandleTypeDef
  81. #else
  82. typedef struct
  83. #endif
  84. {
  85. GFXMMU_TypeDef *Instance; /*!< GFXMMU instance */
  86. GFXMMU_InitTypeDef Init; /*!< GFXMMU init parameters */
  87. HAL_GFXMMU_StateTypeDef State; /*!< GFXMMU state */
  88. __IO uint32_t ErrorCode; /*!< GFXMMU error code */
  89. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  90. void (*ErrorCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU error callback */
  91. void (*MspInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP init callback */
  92. void (*MspDeInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP de-init callback */
  93. #endif
  94. }GFXMMU_HandleTypeDef;
  95. /**
  96. * @brief GFXMMU LUT line structure definition
  97. */
  98. typedef struct
  99. {
  100. uint32_t LineNumber; /*!< LUT line number.
  101. This parameter must be a number between Min_Data = 0 and Max_Data = 1023. */
  102. uint32_t LineStatus; /*!< LUT line enable/disable.
  103. This parameter can be a value of @ref GFXMMU_LutLineStatus. */
  104. uint32_t FirstVisibleBlock; /*!< First visible block on this line.
  105. This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
  106. uint32_t LastVisibleBlock; /*!< Last visible block on this line.
  107. This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
  108. int32_t LineOffset; /*!< Offset of block 0 of the current line in physical buffer.
  109. This parameter must be a number between Min_Data = -4080 and Max_Data = 4190208.
  110. @note: Line offset has to be computed with the following formula:
  111. LineOffset = [(Blocks already used) - (1st visible block)]*BlockSize. */
  112. }GFXMMU_LutLineTypeDef;
  113. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  114. /**
  115. * @brief GFXMMU callback ID enumeration definition
  116. */
  117. typedef enum
  118. {
  119. HAL_GFXMMU_ERROR_CB_ID = 0x00U, /*!< GFXMMU error callback ID */
  120. HAL_GFXMMU_MSPINIT_CB_ID = 0x01U, /*!< GFXMMU MSP init callback ID */
  121. HAL_GFXMMU_MSPDEINIT_CB_ID = 0x02U /*!< GFXMMU MSP de-init callback ID */
  122. }HAL_GFXMMU_CallbackIDTypeDef;
  123. /**
  124. * @brief GFXMMU callback pointer definition
  125. */
  126. typedef void (*pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu);
  127. #endif
  128. /**
  129. * @}
  130. */
  131. /* End of exported types -----------------------------------------------------*/
  132. /* Exported constants --------------------------------------------------------*/
  133. /** @defgroup GFXMMU_Exported_Constants GFXMMU Exported Constants
  134. * @{
  135. */
  136. /** @defgroup GFXMMU_BlocksPerLine GFXMMU blocks per line
  137. * @{
  138. */
  139. #define GFXMMU_256BLOCKS 0x00000000U /*!< 256 blocks of 16 bytes per line */
  140. #define GFXMMU_192BLOCKS GFXMMU_CR_192BM /*!< 192 blocks of 16 bytes per line */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup GFXMMU_Interrupts GFXMMU interrupts
  145. * @{
  146. */
  147. #define GFXMMU_AHB_MASTER_ERROR_IT GFXMMU_CR_AMEIE /*!< AHB master error interrupt */
  148. #define GFXMMU_BUFFER0_OVERFLOW_IT GFXMMU_CR_B0OIE /*!< Buffer 0 overflow interrupt */
  149. #define GFXMMU_BUFFER1_OVERFLOW_IT GFXMMU_CR_B1OIE /*!< Buffer 1 overflow interrupt */
  150. #define GFXMMU_BUFFER2_OVERFLOW_IT GFXMMU_CR_B2OIE /*!< Buffer 2 overflow interrupt */
  151. #define GFXMMU_BUFFER3_OVERFLOW_IT GFXMMU_CR_B3OIE /*!< Buffer 3 overflow interrupt */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup GFXMMU_Error_Code GFXMMU Error Code
  156. * @{
  157. */
  158. #define GFXMMU_ERROR_NONE 0x00000000U /*!< No error */
  159. #define GFXMMU_ERROR_BUFFER0_OVERFLOW GFXMMU_SR_B0OF /*!< Buffer 0 overflow */
  160. #define GFXMMU_ERROR_BUFFER1_OVERFLOW GFXMMU_SR_B1OF /*!< Buffer 1 overflow */
  161. #define GFXMMU_ERROR_BUFFER2_OVERFLOW GFXMMU_SR_B2OF /*!< Buffer 2 overflow */
  162. #define GFXMMU_ERROR_BUFFER3_OVERFLOW GFXMMU_SR_B3OF /*!< Buffer 3 overflow */
  163. #define GFXMMU_ERROR_AHB_MASTER GFXMMU_SR_AMEF /*!< AHB master error */
  164. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  165. #define GFXMMU_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid callback error */
  166. #endif
  167. /**
  168. * @}
  169. */
  170. /** @defgroup GFXMMU_LutLineStatus GFXMMU LUT line status
  171. * @{
  172. */
  173. #define GFXMMU_LUT_LINE_DISABLE 0x00000000U /*!< LUT line disabled */
  174. #define GFXMMU_LUT_LINE_ENABLE GFXMMU_LUTxL_EN /*!< LUT line enabled */
  175. /**
  176. * @}
  177. */
  178. /**
  179. * @}
  180. */
  181. /* End of exported constants -------------------------------------------------*/
  182. /* Exported macros -----------------------------------------------------------*/
  183. /** @defgroup GFXMMU_Exported_Macros GFXMMU Exported Macros
  184. * @{
  185. */
  186. /** @brief Reset GFXMMU handle state.
  187. * @param __HANDLE__ GFXMMU handle.
  188. * @retval None
  189. */
  190. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  191. #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) do{ \
  192. (__HANDLE__)->State = HAL_GFXMMU_STATE_RESET; \
  193. (__HANDLE__)->MspInitCallback = NULL; \
  194. (__HANDLE__)->MspDeInitCallback = NULL; \
  195. } while(0)
  196. #else
  197. #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_GFXMMU_STATE_RESET)
  198. #endif
  199. /**
  200. * @}
  201. */
  202. /* End of exported macros ----------------------------------------------------*/
  203. /* Exported functions --------------------------------------------------------*/
  204. /** @addtogroup GFXMMU_Exported_Functions GFXMMU Exported Functions
  205. * @{
  206. */
  207. /** @addtogroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions
  208. * @{
  209. */
  210. /* Initialization and de-initialization functions *****************************/
  211. HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu);
  212. HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu);
  213. void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu);
  214. void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu);
  215. #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
  216. /* GFXMMU callbacks register/unregister functions *****************************/
  217. HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu,
  218. HAL_GFXMMU_CallbackIDTypeDef CallbackID,
  219. pGFXMMU_CallbackTypeDef pCallback);
  220. HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu,
  221. HAL_GFXMMU_CallbackIDTypeDef CallbackID);
  222. #endif
  223. /**
  224. * @}
  225. */
  226. /** @addtogroup GFXMMU_Exported_Functions_Group2 Operations functions
  227. * @{
  228. */
  229. /* Operation functions ********************************************************/
  230. HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
  231. uint32_t FirstLine,
  232. uint32_t LinesNumber,
  233. uint32_t Address);
  234. HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
  235. uint32_t FirstLine,
  236. uint32_t LinesNumber);
  237. HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine);
  238. HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers);
  239. void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu);
  240. void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu);
  241. /**
  242. * @}
  243. */
  244. /** @defgroup GFXMMU_Exported_Functions_Group3 State functions
  245. * @{
  246. */
  247. /* State function *************************************************************/
  248. HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu);
  249. uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu);
  250. /**
  251. * @}
  252. */
  253. /**
  254. * @}
  255. */
  256. /* End of exported functions -------------------------------------------------*/
  257. /* Private macros ------------------------------------------------------------*/
  258. /** @defgroup GFXMMU_Private_Macros GFXMMU Private Macros
  259. * @{
  260. */
  261. #define IS_GFXMMU_BLOCKS_PER_LINE(VALUE) (((VALUE) == GFXMMU_256BLOCKS) || \
  262. ((VALUE) == GFXMMU_192BLOCKS))
  263. #define IS_GFXMMU_BUFFER_ADDRESS(VALUE) (((VALUE) & 0xFU) == 0U)
  264. #define IS_GFXMMU_INTERRUPTS(VALUE) (((VALUE) & 0x1FU) != 0U)
  265. #define IS_GFXMMU_LUT_LINE(VALUE) ((VALUE) < 1024U)
  266. #define IS_GFXMMU_LUT_LINES_NUMBER(VALUE) (((VALUE) > 0U) && ((VALUE) <= 1024U))
  267. #define IS_GFXMMU_LUT_LINE_STATUS(VALUE) (((VALUE) == GFXMMU_LUT_LINE_DISABLE) || \
  268. ((VALUE) == GFXMMU_LUT_LINE_ENABLE))
  269. #define IS_GFXMMU_LUT_BLOCK(VALUE) ((VALUE) < 256U)
  270. #define IS_GFXMMU_LUT_LINE_OFFSET(VALUE) (((VALUE) >= -4080) && ((VALUE) <= 4190208))
  271. /**
  272. * @}
  273. */
  274. /* End of private macros -----------------------------------------------------*/
  275. /**
  276. * @}
  277. */
  278. /**
  279. * @}
  280. */
  281. #endif /* GFXMMU */
  282. #ifdef __cplusplus
  283. }
  284. #endif
  285. #endif /* STM32L4xx_HAL_GFXMMU_H */