STM32L486xx HAL User Manual
stm32l4xx_hal_gfxmmu.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_gfxmmu.c
00004   * @author  MCD Application Team
00005   * @brief   This file provides firmware functions to manage the following 
00006   *          functionalities of the Graphic MMU (GFXMMU) peripheral:
00007   *           + Initialization and De-initialization.
00008   *           + LUT configuration.
00009   *           + Modify physical buffer adresses.
00010   *           + Error management.
00011   *         
00012   @verbatim
00013   ==============================================================================
00014                      ##### How to use this driver #####
00015   ==============================================================================
00016   [..]
00017     *** Initialization ***
00018     ======================
00019     [..]
00020       (#) As prerequisite, fill in the HAL_GFXMMU_MspInit() :
00021         (++) Enable GFXMMU clock interface with __HAL_RCC_GFXMMU_CLK_ENABLE().
00022         (++) If interrupts are used, enable and configure GFXMMU global
00023             interrupt with HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ().
00024       (#) Configure the number of blocks per line, default value, physical 
00025           buffer addresses and interrupts using the HAL_GFXMMU_Init() function.
00026 
00027     *** LUT configuration ***
00028     =========================
00029     [..]
00030       (#) Use HAL_GFXMMU_DisableLutLines() to deactivate all LUT lines (or a
00031           range of lines).
00032       (#) Use HAL_GFXMMU_ConfigLut() to copy LUT from flash to look up RAM.
00033       (#) Use HAL_GFXMMU_ConfigLutLine() to configure one line of LUT.
00034 
00035     *** Modify physical buffer adresses ***
00036     =======================================
00037     [..]    
00038       (#) Use HAL_GFXMMU_ModifyBuffers() to modify physical buffer addresses.
00039 
00040     *** Error management ***
00041     ========================
00042     [..]
00043       (#) If interrupts are used, HAL_GFXMMU_IRQHandler() will be called when
00044           an error occurs. This function will call HAL_GFXMMU_ErrorCallback().
00045           Use HAL_GFXMMU_GetError() to get the error code.
00046 
00047     *** De-initialization ***
00048     =========================
00049     [..]    
00050       (#) As prerequisite, fill in the HAL_GFXMMU_MspDeInit() :
00051         (++) Disable GFXMMU clock interface with __HAL_RCC_GFXMMU_CLK_ENABLE().
00052         (++) If interrupts has been used, disable GFXMMU global interrupt with
00053              HAL_NVIC_DisableIRQ().
00054       (#) De-initialize GFXMMU using the HAL_GFXMMU_DeInit() function.
00055 
00056     *** Callback registration ***
00057     =============================
00058 
00059     The compilation define USE_HAL_GFXMMU_REGISTER_CALLBACKS when set to 1
00060     allows the user to configure dynamically the driver callbacks.
00061     Use functions @ref HAL_GFXMMU_RegisterCallback() to register a user callback.
00062 
00063     Function @ref HAL_GFXMMU_RegisterCallback() allows to register following callbacks:
00064       (+) ErrorCallback      : GFXMMU error.
00065       (+) MspInitCallback    : GFXMMU MspInit.
00066       (+) MspDeInitCallback  : GFXMMU MspDeInit.
00067     This function takes as parameters the HAL peripheral handle, the callback ID
00068     and a pointer to the user callback function.
00069 
00070     Use function @ref HAL_GFXMMU_UnRegisterCallback() to reset a callback to the default
00071     weak (surcharged) function.
00072     @ref HAL_GFXMMU_UnRegisterCallback() takes as parameters the HAL peripheral handle,
00073     and the callback ID.
00074     This function allows to reset following callbacks:
00075       (+) ErrorCallback      : GFXMMU error.
00076       (+) MspInitCallback    : GFXMMU MspInit.
00077       (+) MspDeInitCallback  : GFXMMU MspDeInit.
00078 
00079     By default, after the @ref HAL_GFXMMU_Init and if the state is HAL_GFXMMU_STATE_RESET
00080     all callbacks are reset to the corresponding legacy weak (surcharged) functions:
00081     examples @ref HAL_GFXMMU_ErrorCallback().
00082     Exception done for MspInit and MspDeInit callbacks that are respectively
00083     reset to the legacy weak (surcharged) functions in the @ref HAL_GFXMMU_Init
00084     and @ref  HAL_GFXMMU_DeInit only when these callbacks are null (not registered beforehand).
00085     If not, MspInit or MspDeInit are not null, the @ref HAL_GFXMMU_Init and @ref HAL_GFXMMU_DeInit
00086     keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
00087 
00088     Callbacks can be registered/unregistered in READY state only.
00089     Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
00090     in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
00091     during the Init/DeInit.
00092     In that case first register the MspInit/MspDeInit user callbacks
00093     using @ref HAL_GFXMMU_RegisterCallback before calling @ref HAL_GFXMMU_DeInit
00094     or @ref HAL_GFXMMU_Init function.
00095 
00096     When the compilation define USE_HAL_GFXMMU_REGISTER_CALLBACKS is set to 0 or
00097     not defined, the callback registering feature is not available
00098     and weak (surcharged) callbacks are used.
00099 
00100   @endverbatim
00101   ******************************************************************************
00102   * @attention
00103   *
00104   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00105   *
00106   * Redistribution and use in source and binary forms, with or without modification,
00107   * are permitted provided that the following conditions are met:
00108   *   1. Redistributions of source code must retain the above copyright notice,
00109   *      this list of conditions and the following disclaimer.
00110   *   2. Redistributions in binary form must reproduce the above copyright notice,
00111   *      this list of conditions and the following disclaimer in the documentation
00112   *      and/or other materials provided with the distribution.
00113   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00114   *      may be used to endorse or promote products derived from this software
00115   *      without specific prior written permission.
00116   *
00117   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00118   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00119   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00120   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00121   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00122   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00123   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00124   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00125   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00126   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00127   *
00128   ******************************************************************************
00129   */
00130 
00131 /* Includes ------------------------------------------------------------------*/
00132 #include "stm32l4xx_hal.h"
00133 
00134 /** @addtogroup STM32L4xx_HAL_Driver
00135   * @{
00136   */
00137 #ifdef HAL_GFXMMU_MODULE_ENABLED
00138 #if defined(GFXMMU)
00139 /** @defgroup GFXMMU GFXMMU
00140   * @brief GFXMMU HAL driver module
00141   * @{
00142   */
00143 
00144 /* Private typedef -----------------------------------------------------------*/
00145 /* Private define ------------------------------------------------------------*/
00146 #define GFXMMU_LUTXL_FVB_OFFSET     8U
00147 #define GFXMMU_LUTXL_LVB_OFFSET     16U
00148 #define GFXMMU_CR_ITS_MASK          0x1FU
00149 /* Private macro -------------------------------------------------------------*/
00150 /* Private variables ---------------------------------------------------------*/
00151 /* Private function prototypes -----------------------------------------------*/
00152 /* Exported functions --------------------------------------------------------*/
00153 /** @defgroup GFXMMU_Exported_Functions GFXMMU Exported Functions
00154   * @{
00155   */
00156 
00157 /** @defgroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions
00158  *  @brief    Initialization and de-initialization functions 
00159  *
00160 @verbatim
00161   ==============================================================================
00162           ##### Initialization and de-initialization functions #####
00163   ==============================================================================
00164     [..]  This section provides functions allowing to:
00165       (+) Initialize the GFXMMU.
00166       (+) De-initialize the GFXMMU.
00167 @endverbatim
00168   * @{
00169   */
00170 
00171 /**
00172   * @brief  Initialize the GFXMMU according to the specified parameters in the
00173   *         GFXMMU_InitTypeDef structure and initialize the associated handle.
00174   * @param  hgfxmmu GFXMMU handle.
00175   * @retval HAL status.
00176   */
00177 HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu)
00178 {
00179   HAL_StatusTypeDef status = HAL_OK;
00180   
00181   /* Check GFXMMU handle */
00182   if(hgfxmmu == NULL)
00183   {
00184     status = HAL_ERROR;
00185   }
00186   else
00187   {
00188     /* Check parameters */
00189     assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00190     assert_param(IS_GFXMMU_BLOCKS_PER_LINE(hgfxmmu->Init.BlocksPerLine));
00191     assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf0Address));
00192     assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf1Address));
00193     assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf2Address));
00194     assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf3Address));
00195     assert_param(IS_FUNCTIONAL_STATE(hgfxmmu->Init.Interrupts.Activation));
00196     
00197 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00198     /* Reset callback pointers to the weak predefined callbacks */
00199     hgfxmmu->ErrorCallback = HAL_GFXMMU_ErrorCallback;
00200 
00201     /* Call GFXMMU MSP init function */
00202     if(hgfxmmu->MspInitCallback == NULL)
00203     {
00204       hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
00205     }
00206     hgfxmmu->MspInitCallback(hgfxmmu);
00207 #else
00208     /* Call GFXMMU MSP init function */
00209     HAL_GFXMMU_MspInit(hgfxmmu);
00210 #endif
00211     
00212     /* Configure blocks per line and interrupts parameters on GFXMMU_CR register */
00213     hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
00214                                GFXMMU_CR_AMEIE | GFXMMU_CR_192BM);
00215     hgfxmmu->Instance->CR |= (hgfxmmu->Init.BlocksPerLine);
00216     if(hgfxmmu->Init.Interrupts.Activation == ENABLE)
00217     {
00218       assert_param(IS_GFXMMU_INTERRUPTS(hgfxmmu->Init.Interrupts.UsedInterrupts));
00219       hgfxmmu->Instance->CR |= hgfxmmu->Init.Interrupts.UsedInterrupts;
00220     }
00221     
00222     /* Configure default value on GFXMMU_DVR register */
00223     hgfxmmu->Instance->DVR = hgfxmmu->Init.DefaultValue;
00224     
00225     /* Configure physical buffer adresses on GFXMMU_BxCR registers */
00226     hgfxmmu->Instance->B0CR = hgfxmmu->Init.Buffers.Buf0Address;
00227     hgfxmmu->Instance->B1CR = hgfxmmu->Init.Buffers.Buf1Address;
00228     hgfxmmu->Instance->B2CR = hgfxmmu->Init.Buffers.Buf2Address;
00229     hgfxmmu->Instance->B3CR = hgfxmmu->Init.Buffers.Buf3Address;
00230     
00231     /* Reset GFXMMU error code */
00232     hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
00233     
00234     /* Set GFXMMU to ready state */
00235     hgfxmmu->State = HAL_GFXMMU_STATE_READY;
00236   }
00237   /* Return function status */
00238   return status;
00239 }
00240 
00241 /**
00242   * @brief  De-initialize the GFXMMU.
00243   * @param  hgfxmmu GFXMMU handle.
00244   * @retval HAL status.
00245   */
00246 HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu)
00247 {
00248   HAL_StatusTypeDef status = HAL_OK;
00249   
00250   /* Check GFXMMU handle */
00251   if(hgfxmmu == NULL)
00252   {
00253     status = HAL_ERROR;
00254   }
00255   else
00256   {
00257     /* Check parameters */
00258     assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00259     
00260     /* Disable all interrupts on GFXMMU_CR register */
00261     hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
00262                                GFXMMU_CR_AMEIE);
00263     
00264     /* Call GFXMMU MSP de-init function */
00265 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00266     if(hgfxmmu->MspDeInitCallback == NULL)
00267     {
00268       hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
00269     }
00270     hgfxmmu->MspDeInitCallback(hgfxmmu);
00271 #else
00272     HAL_GFXMMU_MspDeInit(hgfxmmu);
00273 #endif
00274     
00275     /* Set GFXMMU to reset state */
00276     hgfxmmu->State = HAL_GFXMMU_STATE_RESET;
00277   }
00278   /* Return function status */
00279   return status;
00280 }
00281 
00282 /**
00283   * @brief  Initialize the GFXMMU MSP.
00284   * @param  hgfxmmu GFXMMU handle.
00285   * @retval None.
00286   */
00287 __weak void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu)
00288 {
00289   /* Prevent unused argument(s) compilation warning */
00290   UNUSED(hgfxmmu);
00291   
00292   /* NOTE : This function should not be modified, when the function is needed,
00293             the HAL_GFXMMU_MspInit could be implemented in the user file.
00294    */
00295 }
00296 
00297 /**
00298   * @brief  De-initialize the GFXMMU MSP.
00299   * @param  hgfxmmu GFXMMU handle.
00300   * @retval None.
00301   */
00302 __weak void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu)
00303 {
00304   /* Prevent unused argument(s) compilation warning */
00305   UNUSED(hgfxmmu);
00306   
00307   /* NOTE : This function should not be modified, when the function is needed,
00308             the HAL_GFXMMU_MspDeInit could be implemented in the user file.
00309    */
00310 }
00311 
00312 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00313 /**
00314   * @brief  Register a user GFXMMU callback
00315   *         to be used instead of the weak predefined callback.
00316   * @param  hgfxmmu GFXMMU handle.
00317   * @param  CallbackID ID of the callback to be registered.
00318   *         This parameter can be one of the following values:
00319   *           @arg @ref HAL_GFXMMU_ERROR_CB_ID error callback ID.
00320   *           @arg @ref HAL_GFXMMU_MSPINIT_CB_ID MSP init callback ID.
00321   *           @arg @ref HAL_GFXMMU_MSPDEINIT_CB_ID MSP de-init callback ID.
00322   * @param  pCallback pointer to the callback function.
00323   * @retval HAL status.
00324   */
00325 HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
00326                                               HAL_GFXMMU_CallbackIDTypeDef CallbackID,
00327                                               pGFXMMU_CallbackTypeDef      pCallback)
00328 {
00329   HAL_StatusTypeDef status = HAL_OK;
00330 
00331   if(pCallback == NULL)
00332   {
00333     /* update the error code */
00334     hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00335     /* update return status */
00336     status = HAL_ERROR;
00337   }
00338   else
00339   {
00340     if(HAL_GFXMMU_STATE_READY == hgfxmmu->State)
00341     {
00342       switch (CallbackID)
00343       {
00344       case HAL_GFXMMU_ERROR_CB_ID :
00345         hgfxmmu->ErrorCallback = pCallback;
00346         break;
00347       case HAL_GFXMMU_MSPINIT_CB_ID :
00348         hgfxmmu->MspInitCallback = pCallback;
00349         break;
00350       case HAL_GFXMMU_MSPDEINIT_CB_ID :
00351         hgfxmmu->MspDeInitCallback = pCallback;
00352         break;
00353       default :
00354         /* update the error code */
00355         hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00356         /* update return status */
00357         status = HAL_ERROR;
00358         break;
00359       }
00360     }
00361     else if(HAL_GFXMMU_STATE_RESET == hgfxmmu->State)
00362     {
00363       switch (CallbackID)
00364       {
00365       case HAL_GFXMMU_MSPINIT_CB_ID :
00366         hgfxmmu->MspInitCallback = pCallback;
00367         break;
00368       case HAL_GFXMMU_MSPDEINIT_CB_ID :
00369         hgfxmmu->MspDeInitCallback = pCallback;
00370         break;
00371       default :
00372         /* update the error code */
00373         hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00374         /* update return status */
00375         status = HAL_ERROR;
00376         break;
00377       }
00378     }
00379     else
00380     {
00381       /* update the error code */
00382       hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00383       /* update return status */
00384       status = HAL_ERROR;
00385     }
00386   }
00387   return status;
00388 }
00389 
00390 /**
00391   * @brief  Unregister a user GFXMMU callback.
00392   *         GFXMMU callback is redirected to the weak predefined callback.
00393   * @param  hgfxmmu GFXMMU handle.
00394   * @param  CallbackID ID of the callback to be unregistered.
00395   *         This parameter can be one of the following values:
00396   *           @arg @ref HAL_GFXMMU_ERROR_CB_ID error callback ID.
00397   *           @arg @ref HAL_GFXMMU_MSPINIT_CB_ID MSP init callback ID.
00398   *           @arg @ref HAL_GFXMMU_MSPDEINIT_CB_ID MSP de-init callback ID.
00399   * @retval HAL status.
00400   */
00401 HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
00402                                                 HAL_GFXMMU_CallbackIDTypeDef CallbackID)
00403 {
00404   HAL_StatusTypeDef status = HAL_OK;
00405 
00406   if(HAL_GFXMMU_STATE_READY == hgfxmmu->State)
00407   {
00408     switch (CallbackID)
00409     {
00410     case HAL_GFXMMU_ERROR_CB_ID :
00411       hgfxmmu->ErrorCallback = HAL_GFXMMU_ErrorCallback;
00412       break;
00413     case HAL_GFXMMU_MSPINIT_CB_ID :
00414       hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
00415       break;
00416     case HAL_GFXMMU_MSPDEINIT_CB_ID :
00417       hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
00418       break;
00419     default :
00420       /* update the error code */
00421       hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00422       /* update return status */
00423       status = HAL_ERROR;
00424       break;
00425     }
00426   }
00427   else if(HAL_GFXMMU_STATE_RESET == hgfxmmu->State)
00428   {
00429     switch (CallbackID)
00430     {
00431     case HAL_GFXMMU_MSPINIT_CB_ID :
00432       hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
00433       break;
00434     case HAL_GFXMMU_MSPDEINIT_CB_ID :
00435       hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
00436       break;
00437     default :
00438       /* update the error code */
00439       hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00440       /* update return status */
00441       status = HAL_ERROR;
00442       break;
00443     }
00444   }
00445   else
00446   {
00447     /* update the error code */
00448     hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
00449     /* update return status */
00450     status = HAL_ERROR;
00451   }
00452   return status;
00453 }
00454 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */
00455 
00456 /**
00457   * @}
00458   */
00459 
00460 /** @defgroup GFXMMU_Exported_Functions_Group2 Operations functions
00461  *  @brief    GFXMMU operation functions
00462  *
00463 @verbatim
00464   ==============================================================================
00465                       ##### Operation functions #####
00466   ==============================================================================
00467     [..]  This section provides functions allowing to:
00468       (+) Configure LUT.
00469       (+) Modify physical buffer adresses.
00470       (+) Manage error.
00471 @endverbatim
00472   * @{
00473   */
00474 
00475 /**
00476   * @brief  This function allows to copy LUT from flash to look up RAM.
00477   * @param  hgfxmmu GFXMMU handle.
00478   * @param  FirstLine First line enabled on LUT.
00479   *         This parameter must be a number between Min_Data = 0 and Max_Data = 1023.
00480   * @param  LinesNumber Number of lines enabled on LUT.
00481   *         This parameter must be a number between Min_Data = 1 and Max_Data = 1024.
00482   * @param  Address Start address of LUT in flash.
00483   * @retval HAL status.
00484   */
00485 HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
00486                                        uint32_t FirstLine,
00487                                        uint32_t LinesNumber,
00488                                        uint32_t Address)
00489 {
00490   HAL_StatusTypeDef status = HAL_OK;
00491   
00492   /* Check parameters */
00493   assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00494   assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
00495   assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
00496   
00497   /* Check GFXMMU state and coherent parameters */
00498   if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
00499   {
00500     status = HAL_ERROR;
00501   }
00502   else
00503   {
00504     uint32_t current_address, current_line, lutxl_address, lutxh_address;
00505     
00506     /* Initialize local variables */
00507     current_address = Address;
00508     current_line    = 0U;
00509     lutxl_address   = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
00510     lutxh_address   = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
00511     
00512     /* Copy LUT from flash to look up RAM */
00513     while(current_line < LinesNumber)
00514     {
00515       *((uint32_t *)lutxl_address) = *((uint32_t *)current_address);
00516       current_address += 4U;
00517       *((uint32_t *)lutxh_address) = *((uint32_t *)current_address);
00518       current_address += 4U;
00519       lutxl_address += 8U;
00520       lutxh_address += 8U;
00521       current_line++;
00522     }
00523   }
00524   /* Return function status */
00525   return status;
00526 }
00527 
00528 /**
00529   * @brief  This function allows to disable a range of LUT lines.
00530   * @param  hgfxmmu GFXMMU handle.
00531   * @param  FirstLine First line to disable on LUT.
00532   *         This parameter must be a number between Min_Data = 0 and Max_Data = 1023.
00533   * @param  LinesNumber Number of lines to disable on LUT.
00534   *         This parameter must be a number between Min_Data = 1 and Max_Data = 1024.
00535   * @retval HAL status.
00536   */
00537 HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
00538                                              uint32_t FirstLine,
00539                                              uint32_t LinesNumber)
00540 {
00541   HAL_StatusTypeDef status = HAL_OK;
00542   
00543   /* Check parameters */
00544   assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00545   assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
00546   assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
00547   
00548   /* Check GFXMMU state and coherent parameters */
00549   if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
00550   {
00551     status = HAL_ERROR;
00552   }
00553   else
00554   {
00555     uint32_t current_line, lutxl_address, lutxh_address;
00556     
00557     /* Initialize local variables */
00558     current_line    = 0U;
00559     lutxl_address   = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
00560     lutxh_address   = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
00561     
00562     /* Disable LUT lines */
00563     while(current_line < LinesNumber)
00564     {
00565       *((uint32_t *)lutxl_address) = 0U;
00566       *((uint32_t *)lutxh_address) = 0U;
00567       lutxl_address += 8U;
00568       lutxh_address += 8U;
00569       current_line++;
00570     }
00571   }
00572   /* Return function status */
00573   return status;
00574 }
00575 
00576 /**
00577   * @brief  This function allows to configure one line of LUT.
00578   * @param  hgfxmmu GFXMMU handle.
00579   * @param  lutLine LUT line parameters.
00580   * @retval HAL status.
00581   */
00582 HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine)
00583 {
00584   HAL_StatusTypeDef status = HAL_OK;
00585   
00586   /* Check parameters */
00587   assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00588   assert_param(IS_GFXMMU_LUT_LINE(lutLine->LineNumber));
00589   assert_param(IS_GFXMMU_LUT_LINE_STATUS(lutLine->LineStatus));
00590   assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->FirstVisibleBlock));
00591   assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->LastVisibleBlock));
00592   assert_param(IS_GFXMMU_LUT_LINE_OFFSET(lutLine->LineOffset));
00593   
00594   /* Check GFXMMU state */
00595   if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
00596   {
00597     status = HAL_ERROR;
00598   }
00599   else
00600   {
00601     uint32_t lutxl_address, lutxh_address;
00602     
00603     /* Initialize local variables */
00604     lutxl_address   = (uint32_t) &(hgfxmmu->Instance->LUT[2U * lutLine->LineNumber]);
00605     lutxh_address   = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * lutLine->LineNumber) + 1U]);
00606     
00607     /* Configure LUT line */
00608     if(lutLine->LineStatus == GFXMMU_LUT_LINE_ENABLE)
00609     {
00610       /* Enable and configure LUT line */
00611       *((uint32_t *)lutxl_address) = (lutLine->LineStatus | 
00612                                      (lutLine->FirstVisibleBlock << GFXMMU_LUTXL_FVB_OFFSET) | 
00613                                      (lutLine->LastVisibleBlock << GFXMMU_LUTXL_LVB_OFFSET));
00614       *((uint32_t *)lutxh_address) = (uint32_t) lutLine->LineOffset;
00615     }
00616     else
00617     {
00618       /* Disable LUT line */
00619       *((uint32_t *)lutxl_address) = 0U;
00620       *((uint32_t *)lutxh_address) = 0U;
00621     }
00622   }
00623   /* Return function status */
00624   return status;
00625 }
00626 
00627 /**
00628   * @brief  This function allows to modify physical buffer addresses.
00629   * @param  hgfxmmu GFXMMU handle.
00630   * @param  Buffers Buffers parameters.
00631   * @retval HAL status.
00632   */
00633 HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers)
00634 {
00635   HAL_StatusTypeDef status = HAL_OK;
00636   
00637   /* Check parameters */
00638   assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
00639   assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf0Address));
00640   assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf1Address));
00641   assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf2Address));
00642   assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf3Address));
00643   
00644   /* Check GFXMMU state */
00645   if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
00646   {
00647     status = HAL_ERROR;
00648   }
00649   else
00650   {
00651     /* Modify physical buffer adresses on GFXMMU_BxCR registers */
00652     hgfxmmu->Instance->B0CR = Buffers->Buf0Address;
00653     hgfxmmu->Instance->B1CR = Buffers->Buf1Address;
00654     hgfxmmu->Instance->B2CR = Buffers->Buf2Address;
00655     hgfxmmu->Instance->B3CR = Buffers->Buf3Address;
00656   }
00657   /* Return function status */
00658   return status;
00659 }
00660 
00661 /**
00662   * @brief  This function handles the GFXMMU interrupts.
00663   * @param  hgfxmmu GFXMMU handle.
00664   * @retval None.
00665   */
00666 void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu)
00667 {
00668   uint32_t flags, interrupts, error;
00669   
00670   /* Read current flags and interrupts and determine which error occurs */
00671   flags = hgfxmmu->Instance->SR;
00672   interrupts = (hgfxmmu->Instance->CR & GFXMMU_CR_ITS_MASK);
00673   error = (flags & interrupts);
00674   
00675   if(error != 0U)
00676   {
00677     /* Clear flags on GFXMMU_FCR register */
00678     hgfxmmu->Instance->FCR = error;
00679     
00680     /* Update GFXMMU error code */
00681     hgfxmmu->ErrorCode |= error;
00682     
00683     /* Call GFXMMU error callback */
00684 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
00685     hgfxmmu->ErrorCallback(hgfxmmu);
00686 #else
00687     HAL_GFXMMU_ErrorCallback(hgfxmmu);
00688 #endif
00689   }
00690 }
00691 
00692 /**
00693   * @brief  Error callback. 
00694   * @param  hgfxmmu GFXMMU handle.
00695   * @retval None.
00696   */
00697 __weak void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu)
00698 {
00699   /* Prevent unused argument(s) compilation warning */
00700   UNUSED(hgfxmmu);
00701   
00702   /* NOTE : This function should not be modified, when the callback is needed,
00703             the HAL_GFXMMU_ErrorCallback could be implemented in the user file.
00704    */
00705 }
00706 
00707 /**
00708   * @}
00709   */
00710 
00711 /** @defgroup GFXMMU_Exported_Functions_Group3 State functions
00712  *  @brief    GFXMMU state functions
00713  *
00714 @verbatim
00715   ==============================================================================
00716                          ##### State functions #####
00717   ==============================================================================
00718     [..]  This section provides functions allowing to:
00719       (+) Get GFXMMU handle state.
00720       (+) Get GFXMMU error code.
00721 @endverbatim
00722   * @{
00723   */
00724 
00725 /**
00726   * @brief  This function allows to get the current GFXMMU handle state.
00727   * @param  hgfxmmu GFXMMU handle.
00728   * @retval GFXMMU state.
00729   */
00730 HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu)
00731 {
00732   /* Return GFXMMU handle state */
00733   return hgfxmmu->State;
00734 }
00735 
00736 /**
00737   * @brief  This function allows to get the current GFXMMU error code.
00738   * @param  hgfxmmu GFXMMU handle.
00739   * @retval GFXMMU error code.
00740   */
00741 uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu)
00742 {
00743   uint32_t error_code;
00744   
00745   /* Enter in critical section */
00746   __disable_irq();  
00747   
00748   /* Store and reset GFXMMU error code */
00749   error_code = hgfxmmu->ErrorCode;
00750   hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
00751   
00752   /* Exit from critical section */
00753   __enable_irq();
00754   
00755   /* Return GFXMMU error code */
00756   return error_code;
00757 }
00758 
00759 /**
00760   * @}
00761   */
00762 
00763 /**
00764   * @}
00765   */
00766 /* End of exported functions -------------------------------------------------*/
00767 /* Private functions ---------------------------------------------------------*/
00768 /* End of private functions --------------------------------------------------*/
00769 
00770 /**
00771   * @}
00772   */
00773 #endif /* GFXMMU */
00774 #endif /* HAL_GFXMMU_MODULE_ENABLED */
00775 /**
00776   * @}
00777   */
00778 
00779 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/