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