STM32L486xx HAL User Manual
stm32l4xx_hal_gfxmmu.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_gfxmmu.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of GFXMMU HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */
00035 
00036 /* Define to prevent recursive inclusion -------------------------------------*/
00037 #ifndef STM32L4xx_HAL_GFXMMU_H
00038 #define STM32L4xx_HAL_GFXMMU_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 /* Includes ------------------------------------------------------------------*/
00045 #include "stm32l4xx_hal_def.h"
00046 
00047 #if defined(GFXMMU)
00048 
00049 /** @addtogroup STM32L4xx_HAL_Driver
00050   * @{
00051   */
00052 
00053 /** @addtogroup GFXMMU
00054   * @{
00055   */ 
00056 
00057 /* Exported types ------------------------------------------------------------*/
00058 /** @defgroup GFXMMU_Exported_Types GFXMMU Exported Types
00059   * @{
00060   */
00061 
00062 /** 
00063   * @brief  HAL GFXMMU states definition
00064   */
00065 typedef enum
00066 {
00067   HAL_GFXMMU_STATE_RESET = 0x00U, /*!< GFXMMU not initialized */
00068   HAL_GFXMMU_STATE_READY = 0x01U, /*!< GFXMMU initialized and ready for use */
00069 }HAL_GFXMMU_StateTypeDef;
00070 
00071 /** 
00072   * @brief  GFXMMU buffers structure definition
00073   */
00074 typedef struct
00075 {
00076   uint32_t Buf0Address; /*!< Physical address of buffer 0. */
00077   uint32_t Buf1Address; /*!< Physical address of buffer 1. */
00078   uint32_t Buf2Address; /*!< Physical address of buffer 2. */
00079   uint32_t Buf3Address; /*!< Physical address of buffer 3. */
00080 }GFXMMU_BuffersTypeDef;
00081 
00082 /** 
00083   * @brief  GFXMMU interrupts structure definition
00084   */
00085 typedef struct
00086 {
00087   FunctionalState Activation;     /*!< Interrupts enable/disable */
00088   uint32_t        UsedInterrupts; /*!< Interrupts used.
00089                                        This parameter can be a values combination of @ref GFXMMU_Interrupts.
00090                                        @note: Usefull only when interrupts are enabled. */
00091 }GFXMMU_InterruptsTypeDef;
00092 
00093 /** 
00094   * @brief  GFXMMU init structure definition
00095   */
00096 typedef struct
00097 {
00098   uint32_t                    BlocksPerLine; /*!< Number of blocks of 16 bytes per line.
00099                                                   This parameter can be a value of @ref GFXMMU_BlocksPerLine. */
00100   uint32_t                    DefaultValue;  /*!< Value returned when virtual memory location not physically mapped. */
00101   GFXMMU_BuffersTypeDef       Buffers;       /*!< Physical buffers addresses. */
00102   GFXMMU_InterruptsTypeDef    Interrupts;    /*!< Interrupts parameters. */
00103 }GFXMMU_InitTypeDef;
00104 
00105 /** 
00106   * @brief  GFXMMU handle structure definition
00107   */
00108 typedef struct __GFXMMU_HandleTypeDef
00109 {
00110   GFXMMU_TypeDef          *Instance; /*!< GFXMMU instance */
00111   GFXMMU_InitTypeDef      Init;      /*!< GFXMMU init parameters */
00112   HAL_GFXMMU_StateTypeDef State;     /*!< GFXMMU state */
00113   __IO uint32_t           ErrorCode; /*!< GFXMMU error code */
00114 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00115   void (*ErrorCallback)     (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU error callback */
00116   void (*MspInitCallback)   (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP init callback */
00117   void (*MspDeInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP de-init callback */
00118 #endif
00119 }GFXMMU_HandleTypeDef;
00120 
00121 /** 
00122   * @brief  GFXMMU LUT line structure definition
00123   */
00124 typedef struct
00125 {
00126   uint32_t LineNumber;        /*!< LUT line number.
00127                                    This parameter must be a number between Min_Data = 0 and Max_Data = 1023. */
00128   uint32_t LineStatus;        /*!< LUT line enable/disable.
00129                                    This parameter can be a value of @ref GFXMMU_LutLineStatus. */
00130   uint32_t FirstVisibleBlock; /*!< First visible block on this line.
00131                                    This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
00132   uint32_t LastVisibleBlock;  /*!< Last visible block on this line.
00133                                    This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
00134   int32_t  LineOffset;        /*!< Offset of block 0 of the current line in physical buffer.
00135                                    This parameter must be a number between Min_Data = -4080 and Max_Data = 4190208.
00136                                    @note: Line offset has to be computed with the following formula:
00137                                           LineOffset = [(Blocks already used) - (1st visible block)]*BlockSize. */
00138 }GFXMMU_LutLineTypeDef;
00139 
00140 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00141 /**
00142   * @brief  GFXMMU callback ID enumeration definition
00143   */
00144 typedef enum
00145 {
00146   HAL_GFXMMU_ERROR_CB_ID     = 0x00U, /*!< GFXMMU error callback ID */
00147   HAL_GFXMMU_MSPINIT_CB_ID   = 0x01U, /*!< GFXMMU MSP init callback ID */
00148   HAL_GFXMMU_MSPDEINIT_CB_ID = 0x02U  /*!< GFXMMU MSP de-init callback ID */
00149 }HAL_GFXMMU_CallbackIDTypeDef;
00150 
00151 /**
00152   * @brief  GFXMMU callback pointer definition
00153   */
00154 typedef void (*pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu);
00155 #endif
00156 
00157 /**
00158   * @}
00159   */ 
00160 /* End of exported types -----------------------------------------------------*/
00161 
00162 /* Exported constants --------------------------------------------------------*/
00163 /** @defgroup GFXMMU_Exported_Constants GFXMMU Exported Constants
00164   * @{
00165   */
00166 
00167 /** @defgroup GFXMMU_BlocksPerLine GFXMMU blocks per line
00168   * @{
00169   */
00170 #define GFXMMU_256BLOCKS 0x00000000U     /*!< 256 blocks of 16 bytes per line */
00171 #define GFXMMU_192BLOCKS GFXMMU_CR_192BM /*!< 192 blocks of 16 bytes per line */
00172 /**
00173   * @}
00174   */
00175 
00176 /** @defgroup GFXMMU_Interrupts GFXMMU interrupts
00177   * @{
00178   */
00179 #define GFXMMU_AHB_MASTER_ERROR_IT GFXMMU_CR_AMEIE /*!< AHB master error interrupt */
00180 #define GFXMMU_BUFFER0_OVERFLOW_IT GFXMMU_CR_B0OIE /*!< Buffer 0 overflow interrupt */
00181 #define GFXMMU_BUFFER1_OVERFLOW_IT GFXMMU_CR_B1OIE /*!< Buffer 1 overflow interrupt */
00182 #define GFXMMU_BUFFER2_OVERFLOW_IT GFXMMU_CR_B2OIE /*!< Buffer 2 overflow interrupt */
00183 #define GFXMMU_BUFFER3_OVERFLOW_IT GFXMMU_CR_B3OIE /*!< Buffer 3 overflow interrupt */
00184 /**
00185   * @}
00186   */
00187 
00188 /** @defgroup GFXMMU_Error_Code GFXMMU Error Code
00189   * @{
00190   */
00191 #define GFXMMU_ERROR_NONE             0x00000000U    /*!< No error */
00192 #define GFXMMU_ERROR_BUFFER0_OVERFLOW GFXMMU_SR_B0OF /*!< Buffer 0 overflow */
00193 #define GFXMMU_ERROR_BUFFER1_OVERFLOW GFXMMU_SR_B1OF /*!< Buffer 1 overflow */
00194 #define GFXMMU_ERROR_BUFFER2_OVERFLOW GFXMMU_SR_B2OF /*!< Buffer 2 overflow */
00195 #define GFXMMU_ERROR_BUFFER3_OVERFLOW GFXMMU_SR_B3OF /*!< Buffer 3 overflow */
00196 #define GFXMMU_ERROR_AHB_MASTER       GFXMMU_SR_AMEF /*!< AHB master error */
00197 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00198 #define GFXMMU_ERROR_INVALID_CALLBACK 0x00000100U    /*!< Invalid callback error */
00199 #endif
00200 /**
00201   * @}
00202   */
00203 
00204 /** @defgroup GFXMMU_LutLineStatus GFXMMU LUT line status
00205   * @{
00206   */
00207 #define GFXMMU_LUT_LINE_DISABLE 0x00000000U     /*!< LUT line disabled */
00208 #define GFXMMU_LUT_LINE_ENABLE  GFXMMU_LUTxL_EN /*!< LUT line enabled */
00209 /**
00210   * @}
00211   */
00212 
00213 /**
00214   * @}
00215   */ 
00216 /* End of exported constants -------------------------------------------------*/
00217 
00218 /* Exported macros -----------------------------------------------------------*/
00219 /** @defgroup GFXMMU_Exported_Macros GFXMMU Exported Macros
00220  * @{
00221  */
00222 
00223 /** @brief  Reset GFXMMU handle state.
00224   * @param  __HANDLE__ GFXMMU handle.
00225   * @retval None
00226   */
00227 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00228 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) do{                                               \
00229                                                         (__HANDLE__)->State = HAL_GFXMMU_STATE_RESET; \
00230                                                         (__HANDLE__)->MspInitCallback = NULL;         \
00231                                                         (__HANDLE__)->MspDeInitCallback = NULL;       \
00232                                                       } while(0)
00233 #else
00234 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_GFXMMU_STATE_RESET)
00235 #endif
00236 
00237 /**
00238   * @}
00239   */
00240 /* End of exported macros ----------------------------------------------------*/
00241 
00242 /* Exported functions --------------------------------------------------------*/
00243 /** @addtogroup GFXMMU_Exported_Functions GFXMMU Exported Functions
00244   * @{
00245   */
00246 
00247 /** @addtogroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions
00248   * @{
00249   */
00250 /* Initialization and de-initialization functions *****************************/
00251 HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu);
00252 HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu);
00253 void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu);
00254 void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu);
00255 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00256 /* GFXMMU callbacks register/unregister functions *****************************/
00257 HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
00258                                               HAL_GFXMMU_CallbackIDTypeDef CallbackID,
00259                                               pGFXMMU_CallbackTypeDef      pCallback);
00260 HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
00261                                                 HAL_GFXMMU_CallbackIDTypeDef CallbackID);
00262 #endif
00263 /**
00264   * @}
00265   */
00266 
00267 /** @addtogroup GFXMMU_Exported_Functions_Group2 Operations functions
00268   * @{
00269   */
00270 /* Operation functions ********************************************************/
00271 HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
00272                                        uint32_t FirstLine,
00273                                        uint32_t LinesNumber,
00274                                        uint32_t Address);
00275 
00276 HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
00277                                              uint32_t FirstLine,
00278                                              uint32_t LinesNumber);
00279 
00280 HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine);
00281 
00282 HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers);
00283 
00284 void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu);
00285 
00286 void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu);
00287 /**
00288   * @}
00289   */
00290 
00291 /** @defgroup GFXMMU_Exported_Functions_Group3 State functions
00292   * @{
00293   */
00294 /* State function *************************************************************/
00295 HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu);
00296 
00297 uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu);
00298 /**
00299   * @}
00300   */
00301 
00302 /**
00303   * @}
00304   */
00305 /* End of exported functions -------------------------------------------------*/
00306 
00307 /* Private macros ------------------------------------------------------------*/
00308 /** @defgroup GFXMMU_Private_Macros GFXMMU Private Macros
00309 * @{
00310 */
00311 #define IS_GFXMMU_BLOCKS_PER_LINE(VALUE) (((VALUE) == GFXMMU_256BLOCKS) || \
00312                                           ((VALUE) == GFXMMU_192BLOCKS))
00313 
00314 #define IS_GFXMMU_BUFFER_ADDRESS(VALUE) (((VALUE) & 0xFU) == 0U)
00315 
00316 #define IS_GFXMMU_INTERRUPTS(VALUE) (((VALUE) & 0x1FU) != 0U)
00317 
00318 #define IS_GFXMMU_LUT_LINE(VALUE) ((VALUE) < 1024U)
00319 
00320 #define IS_GFXMMU_LUT_LINES_NUMBER(VALUE) (((VALUE) > 0U) && ((VALUE) <= 1024U))
00321 
00322 #define IS_GFXMMU_LUT_LINE_STATUS(VALUE) (((VALUE) == GFXMMU_LUT_LINE_DISABLE) || \
00323                                           ((VALUE) == GFXMMU_LUT_LINE_ENABLE))
00324 
00325 #define IS_GFXMMU_LUT_BLOCK(VALUE) ((VALUE) < 256U)
00326 
00327 #define IS_GFXMMU_LUT_LINE_OFFSET(VALUE) (((VALUE) >= -4080) && ((VALUE) <= 4190208))
00328 /**
00329   * @}
00330   */ 
00331 /* End of private macros -----------------------------------------------------*/
00332 
00333 /**
00334   * @}
00335   */ 
00336 
00337 /**
00338   * @}
00339   */
00340 #endif /* GFXMMU */
00341 #ifdef __cplusplus
00342 }
00343 #endif
00344 
00345 #endif /* STM32L4xx_HAL_GFXMMU_H */
00346 
00347 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/