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