1 /** 2 ****************************************************************************** 3 * @file stm32h7rsxx_hal_gfxmmu.h 4 * @author MCD Application Team 5 * @brief Header file of GFXMMU HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2022 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 STM32H7RSxx_HAL_GFXMMU_H 21 #define STM32H7RSxx_HAL_GFXMMU_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32h7rsxx_hal_def.h" 29 30 #if defined(GFXMMU) 31 32 /** @addtogroup STM32H7RSxx_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 BlockSize; /*!< Size of virtual memory block. 82 This parameter can be a value of @ref GFXMMU_BlockSize. */ 83 uint32_t DefaultValue; /*!< Value returned when virtual memory location not physically mapped. */ 84 /* @note: Useful only when address translation is enabled. */ 85 FunctionalState AddressTranslation; /*!< Address translation enable/disable. */ 86 GFXMMU_BuffersTypeDef Buffers; /*!< Physical buffers addresses. */ 87 GFXMMU_InterruptsTypeDef Interrupts; /*!< Interrupts parameters. */ 88 } GFXMMU_InitTypeDef; 89 90 /** 91 * @brief GFXMMU handle structure definition 92 */ 93 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 94 typedef struct __GFXMMU_HandleTypeDef 95 #else 96 typedef struct 97 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 98 { 99 GFXMMU_TypeDef *Instance; /*!< GFXMMU instance. */ 100 GFXMMU_InitTypeDef Init; /*!< GFXMMU init parameters. */ 101 HAL_GFXMMU_StateTypeDef State; /*!< GFXMMU state. */ 102 __IO uint32_t ErrorCode; /*!< GFXMMU error code. */ 103 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 104 void (*ErrorCallback)(struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU error callback. */ 105 void (*MspInitCallback)(struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP init callback. */ 106 void (*MspDeInitCallback)(struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP de-init callback. */ 107 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 108 } GFXMMU_HandleTypeDef; 109 110 /** 111 * @brief GFXMMU LUT line structure definition 112 */ 113 typedef struct 114 { 115 uint32_t LineNumber; /*!< LUT line number. 116 This parameter must be a number between Min_Data = 0 and Max_Data = 1023. */ 117 uint32_t LineStatus; /*!< LUT line enable/disable. 118 This parameter can be a value of @ref GFXMMU_LutLineStatus. */ 119 uint32_t FirstVisibleBlock; /*!< First visible block on this line. 120 This parameter must be a number between Min_Data = 0 and Max_Data = 255. */ 121 uint32_t LastVisibleBlock; /*!< Last visible block on this line. 122 This parameter must be a number between Min_Data = 0 and Max_Data = 255. */ 123 int32_t LineOffset; /*!< Offset of block 0 of the current line in physical buffer. 124 This parameter must be a number between Min_Data = -255 and Max_Data = 261888. 125 @note: Line offset has to be computed with the following formula: 126 LineOffset = [(Blocks already used) - (1st visible block)]. */ 127 } GFXMMU_LutLineTypeDef; 128 129 /** 130 * @brief GFXMMU packing structure definition 131 */ 132 typedef struct 133 { 134 FunctionalState Buffer0Activation; /*!< Packing on buffer 0 enable/disable. */ 135 uint32_t Buffer0Mode; /*!< Buffer 0 packing mode. 136 This parameter can be a value of @ref GFXMMU_PackingModes. */ 137 FunctionalState Buffer1Activation; /*!< Packing on buffer 1 enable/disable. */ 138 uint32_t Buffer1Mode; /*!< Buffer 1 packing mode. 139 This parameter can be a value of @ref GFXMMU_PackingModes. */ 140 FunctionalState Buffer2Activation; /*!< Packing on buffer 2 enable/disable. */ 141 uint32_t Buffer2Mode; /*!< Buffer 2 packing mode. 142 This parameter can be a value of @ref GFXMMU_PackingModes. */ 143 FunctionalState Buffer3Activation; /*!< Packing on buffer 3 enable/disable. */ 144 uint32_t Buffer3Mode; /*!< Buffer 3 packing mode. 145 This parameter can be a value of @ref GFXMMU_PackingModes. */ 146 uint32_t DefaultAlpha; /*!< Default alpha value. 147 This parameter must be a number between Min_Data = 0 and Max_Data = 255. */ 148 } GFXMMU_PackingTypeDef; 149 150 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 151 /** 152 * @brief GFXMMU callback ID enumeration definition 153 */ 154 typedef enum 155 { 156 HAL_GFXMMU_ERROR_CB_ID = 0x00U, /*!< GFXMMU error callback ID. */ 157 HAL_GFXMMU_MSPINIT_CB_ID = 0x01U, /*!< GFXMMU MSP init callback ID. */ 158 HAL_GFXMMU_MSPDEINIT_CB_ID = 0x02U /*!< GFXMMU MSP de-init callback ID. */ 159 } HAL_GFXMMU_CallbackIDTypeDef; 160 161 /** 162 * @brief GFXMMU callback pointer definition 163 */ 164 typedef void (*pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu); 165 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 166 167 /** 168 * @} 169 */ 170 /* End of exported types -----------------------------------------------------*/ 171 172 /* Exported constants --------------------------------------------------------*/ 173 /** @defgroup GFXMMU_Exported_Constants GFXMMU Exported Constants 174 * @{ 175 */ 176 177 /** @defgroup GFXMMU_BlockSize GFXMMU block size 178 * @{ 179 */ 180 #define GFXMMU_12BYTE_BLOCKS GFXMMU_CR_BS /*!< Blocks of 12-byte. */ 181 #define GFXMMU_16BYTE_BLOCKS 0x00000000U /*!< Blocks of 16-byte. */ 182 /** 183 * @} 184 */ 185 186 /** @defgroup GFXMMU_Interrupts GFXMMU interrupts 187 * @{ 188 */ 189 #define GFXMMU_BUS_MASTER_ERROR_IT GFXMMU_CR_AMEIE /*!< Bus master error interrupt. */ 190 #define GFXMMU_BUFFER0_OVERFLOW_IT GFXMMU_CR_B0OIE /*!< Buffer 0 overflow interrupt. */ 191 #define GFXMMU_BUFFER1_OVERFLOW_IT GFXMMU_CR_B1OIE /*!< Buffer 1 overflow interrupt. */ 192 #define GFXMMU_BUFFER2_OVERFLOW_IT GFXMMU_CR_B2OIE /*!< Buffer 2 overflow interrupt. */ 193 #define GFXMMU_BUFFER3_OVERFLOW_IT GFXMMU_CR_B3OIE /*!< Buffer 3 overflow interrupt. */ 194 /** 195 * @} 196 */ 197 198 /** @defgroup GFXMMU_Error_Code GFXMMU Error Code 199 * @{ 200 */ 201 #define GFXMMU_ERROR_NONE 0x00000000U /*!< No error. */ 202 #define GFXMMU_ERROR_BUFFER0_OVERFLOW GFXMMU_SR_B0OF /*!< Buffer 0 overflow. */ 203 #define GFXMMU_ERROR_BUFFER1_OVERFLOW GFXMMU_SR_B1OF /*!< Buffer 1 overflow. */ 204 #define GFXMMU_ERROR_BUFFER2_OVERFLOW GFXMMU_SR_B2OF /*!< Buffer 2 overflow. */ 205 #define GFXMMU_ERROR_BUFFER3_OVERFLOW GFXMMU_SR_B3OF /*!< Buffer 3 overflow. */ 206 #define GFXMMU_ERROR_BUS_MASTER GFXMMU_SR_AMEF /*!< Bus master error. */ 207 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 208 #define GFXMMU_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid callback error. */ 209 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 210 /** 211 * @} 212 */ 213 214 /** @defgroup GFXMMU_LutLineStatus GFXMMU LUT line status 215 * @{ 216 */ 217 #define GFXMMU_LUT_LINE_DISABLE 0x00000000U /*!< LUT line disabled. */ 218 #define GFXMMU_LUT_LINE_ENABLE GFXMMU_LUTxL_EN /*!< LUT line enabled. */ 219 /** 220 * @} 221 */ 222 223 /** @defgroup GFXMMU_PackingModes GFXMMU packing modes 224 * @{ 225 */ 226 #define GFXMMU_PACKING_MSB_REMOVE 0x00000000U /*!< Remove MSB during packing operation. */ 227 #define GFXMMU_PACKING_LSB_REMOVE 0x00000001U /*!< Remove LSB during packing operation. */ 228 /** 229 * @} 230 */ 231 232 /** 233 * @} 234 */ 235 /* End of exported constants -------------------------------------------------*/ 236 237 /* Exported macros -----------------------------------------------------------*/ 238 /** @defgroup GFXMMU_Exported_Macros GFXMMU Exported Macros 239 * @{ 240 */ 241 242 /** @brief Reset GFXMMU handle state. 243 * @param __HANDLE__ GFXMMU handle. 244 * @retval None 245 */ 246 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 247 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) do{ \ 248 (__HANDLE__)->State = HAL_GFXMMU_STATE_RESET; \ 249 (__HANDLE__)->MspInitCallback = NULL; \ 250 (__HANDLE__)->MspDeInitCallback = NULL; \ 251 } while(0) 252 #else 253 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_GFXMMU_STATE_RESET) 254 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 255 256 /** 257 * @} 258 */ 259 /* End of exported macros ----------------------------------------------------*/ 260 261 /* Exported functions --------------------------------------------------------*/ 262 /** @addtogroup GFXMMU_Exported_Functions GFXMMU Exported Functions 263 * @{ 264 */ 265 266 /** @addtogroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions 267 * @{ 268 */ 269 /* Initialization and de-initialization functions *****************************/ 270 HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu); 271 HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu); 272 void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu); 273 void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu); 274 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) 275 /* GFXMMU callbacks register/unregister functions *****************************/ 276 HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu, 277 HAL_GFXMMU_CallbackIDTypeDef CallbackID, 278 pGFXMMU_CallbackTypeDef pCallback); 279 HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu, 280 HAL_GFXMMU_CallbackIDTypeDef CallbackID); 281 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ 282 /** 283 * @} 284 */ 285 286 /** @addtogroup GFXMMU_Exported_Functions_Group2 Operations functions 287 * @{ 288 */ 289 /* Operation functions ********************************************************/ 290 HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(const GFXMMU_HandleTypeDef *hgfxmmu, 291 uint32_t FirstLine, 292 uint32_t LinesNumber, 293 uint32_t Address); 294 295 HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(const GFXMMU_HandleTypeDef *hgfxmmu, 296 uint32_t FirstLine, 297 uint32_t LinesNumber); 298 299 HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(const GFXMMU_HandleTypeDef *hgfxmmu, const GFXMMU_LutLineTypeDef *lutLine); 300 301 HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, const GFXMMU_BuffersTypeDef *Buffers); 302 303 HAL_StatusTypeDef HAL_GFXMMU_ConfigPacking(GFXMMU_HandleTypeDef *hgfxmmu, const GFXMMU_PackingTypeDef *pPacking); 304 305 void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu); 306 307 void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu); 308 /** 309 * @} 310 */ 311 312 /** @defgroup GFXMMU_Exported_Functions_Group3 State functions 313 * @{ 314 */ 315 /* State function *************************************************************/ 316 HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(const GFXMMU_HandleTypeDef *hgfxmmu); 317 318 uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu); 319 /** 320 * @} 321 */ 322 323 /** 324 * @} 325 */ 326 /* End of exported functions -------------------------------------------------*/ 327 328 /* Private macros ------------------------------------------------------------*/ 329 /** @defgroup GFXMMU_Private_Macros GFXMMU Private Macros 330 * @{ 331 */ 332 #define IS_GFXMMU_BLOCK_SIZE(VALUE) (((VALUE) == GFXMMU_12BYTE_BLOCKS) || \ 333 ((VALUE) == GFXMMU_16BYTE_BLOCKS)) 334 #define IS_GFXMMU_LUT_LINE_OFFSET(VALUE) (((VALUE) >= -255) && ((VALUE) <= 261888)) 335 336 #define IS_GFXMMU_BUFFER_ADDRESS(VALUE) (((VALUE) & 0xFU) == 0U) 337 338 #define IS_GFXMMU_INTERRUPTS(VALUE) (((VALUE) & 0x1FU) != 0U) 339 340 #define IS_GFXMMU_LUT_LINE(VALUE) ((VALUE) < 1024U) 341 342 #define IS_GFXMMU_LUT_LINES_NUMBER(VALUE) (((VALUE) > 0U) && ((VALUE) <= 1024U)) 343 344 #define IS_GFXMMU_LUT_LINE_STATUS(VALUE) (((VALUE) == GFXMMU_LUT_LINE_DISABLE) || \ 345 ((VALUE) == GFXMMU_LUT_LINE_ENABLE)) 346 347 #define IS_GFXMMU_LUT_BLOCK(VALUE) ((VALUE) < 256U) 348 349 #define IS_GFXMMU_PACKING_MODE(VALUE) (((VALUE) == GFXMMU_PACKING_MSB_REMOVE) || \ 350 ((VALUE) == GFXMMU_PACKING_LSB_REMOVE)) 351 352 #define IS_GFXMMU_DEFAULT_ALPHA_VALUE(VALUE) ((VALUE) < 256U) 353 /** 354 * @} 355 */ 356 /* End of private macros -----------------------------------------------------*/ 357 358 /** 359 * @} 360 */ 361 362 /** 363 * @} 364 */ 365 #endif /* GFXMMU */ 366 #ifdef __cplusplus 367 } 368 #endif 369 370 #endif /* STM32H7RSxx_HAL_GFXMMU_H */ 371