STM32746G-Discovery board drivers V1.0.0

Dependents:   DISCO-F746NG_LCDTS_CC3000_NTP DISCO-F746NG_ROPE_WIFI F746_SpectralAnalysis_NoPhoto ecte433 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers <title>stm32746g_discovery_lcd.c Source File</title>

stm32746g_discovery_lcd.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32746g_discovery_lcd.c
00004   * @author  MCD Application Team
00005   * @brief   This file includes the driver for Liquid Crystal Display (LCD) module
00006   *          mounted on STM32746G-Discovery board.
00007   @verbatim
00008   1. How To use this driver:
00009   --------------------------
00010      - This driver is used to drive directly an LCD TFT using the LTDC controller.
00011      - This driver uses timing and setting for RK043FN48H LCD.
00012   
00013   2. Driver description:
00014   ---------------------
00015     + Initialization steps:
00016        o Initialize the LCD using the BSP_LCD_Init() function.
00017        o Apply the Layer configuration using the BSP_LCD_LayerDefaultInit() function.    
00018        o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
00019        o Enable the LCD display using the BSP_LCD_DisplayOn() function.
00020   
00021     + Options
00022        o Configure and enable the color keying functionality using the 
00023          BSP_LCD_SetColorKeying() function.
00024        o Modify in the fly the transparency and/or the frame buffer address
00025          using the following functions:
00026          - BSP_LCD_SetTransparency()
00027          - BSP_LCD_SetLayerAddress() 
00028     
00029     + Display on LCD
00030        o Clear the hole LCD using BSP_LCD_Clear() function or only one specified string
00031          line using the BSP_LCD_ClearStringLine() function.
00032        o Display a character on the specified line and column using the BSP_LCD_DisplayChar()
00033          function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
00034        o Display a string line on the specified position (x,y in pixel) and align mode
00035          using the BSP_LCD_DisplayStringAtLine() function.          
00036        o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) 
00037          on LCD using the available set of functions.       
00038   @endverbatim
00039   ******************************************************************************
00040   * @attention
00041   *
00042   * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00043   *
00044   * Redistribution and use in source and binary forms, with or without modification,
00045   * are permitted provided that the following conditions are met:
00046   *   1. Redistributions of source code must retain the above copyright notice,
00047   *      this list of conditions and the following disclaimer.
00048   *   2. Redistributions in binary form must reproduce the above copyright notice,
00049   *      this list of conditions and the following disclaimer in the documentation
00050   *      and/or other materials provided with the distribution.
00051   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00052   *      may be used to endorse or promote products derived from this software
00053   *      without specific prior written permission.
00054   *
00055   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00056   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00057   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00058   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00059   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00060   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00061   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00062   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00063   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00064   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00065   *
00066   ******************************************************************************
00067   */ 
00068 
00069 /* Dependencies
00070 - stm32746g_discovery.c
00071 - stm32746g_discovery_sdram.c
00072 - stm32f7xx_hal_ltdc.c
00073 - stm32f7xx_hal_ltdc_ex.c
00074 - stm32f7xx_hal_dma2d.c
00075 - stm32f7xx_hal_rcc_ex.c
00076 - stm32f7xx_hal_gpio.c
00077 - stm32f7xx_hal_cortex.c
00078 - rk043fn48h.h
00079 - fonts.h
00080 - font24.c
00081 - font20.c
00082 - font16.c
00083 - font12.c
00084 - font8.c"
00085 EndDependencies */
00086 
00087 /* Includes ------------------------------------------------------------------*/
00088 #include "stm32746g_discovery_lcd.h"
00089 #include "../../../Utilities/Fonts/fonts.h"
00090 // MBED #include "../../../Utilities/Fonts/font24.c"
00091 // MBED #include "../../../Utilities/Fonts/font20.c"
00092 // MBED #include "../../../Utilities/Fonts/font16.c"
00093 // MBED #include "../../../Utilities/Fonts/font12.c"
00094 // MBED #include "../../../Utilities/Fonts/font8.c"
00095 
00096 /** @addtogroup BSP
00097   * @{
00098   */
00099 
00100 /** @addtogroup STM32746G_DISCOVERY
00101   * @{
00102   */
00103     
00104 /** @addtogroup STM32746G_DISCOVERY_LCD
00105   * @{
00106   */ 
00107 
00108 /** @defgroup STM32746G_DISCOVERY_LCD_Private_TypesDefinitions STM32746G_DISCOVERY_LCD Private Types Definitions
00109   * @{
00110   */ 
00111 /**
00112   * @}
00113   */ 
00114 
00115 /** @defgroup STM32746G_DISCOVERY_LCD_Private_Defines STM32746G_DISCOVERY LCD Private Defines
00116   * @{
00117   */
00118 #define POLY_X(Z)              ((int32_t)((Points + Z)->X))
00119 #define POLY_Y(Z)              ((int32_t)((Points + Z)->Y))      
00120 /**
00121   * @}
00122   */ 
00123 
00124 /** @defgroup STM32746G_DISCOVERY_LCD_Private_Macros STM32746G_DISCOVERY_LCD Private Macros
00125   * @{
00126   */
00127 #define ABS(X)  ((X) > 0 ? (X) : -(X))      
00128 /**
00129   * @}
00130   */ 
00131     
00132 /** @defgroup STM32746G_DISCOVERY_LCD_Private_Variables STM32746G_DISCOVERY_LCD Private Variables
00133   * @{
00134   */ 
00135 LTDC_HandleTypeDef  hLtdcHandler;
00136 static DMA2D_HandleTypeDef hDma2dHandler;
00137 
00138 /* Default LCD configuration with LCD Layer 1 */
00139 static uint32_t            ActiveLayer = 0;
00140 static LCD_DrawPropTypeDef DrawProp[MAX_LAYER_NUMBER];
00141 /**
00142   * @}
00143   */ 
00144 
00145 /** @defgroup STM32746G_DISCOVERY_LCD_Private_FunctionPrototypes STM32746G_DISCOVERY_LCD Private Function Prototypes
00146   * @{
00147   */ 
00148 static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
00149 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
00150 static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex);
00151 static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode);
00152 /**
00153   * @}
00154   */ 
00155 
00156 /** @defgroup STM32746G_DISCOVERY_LCD_Exported_Functions STM32746G_DISCOVERY_LCD Exported Functions
00157   * @{
00158   */
00159 
00160 /**
00161   * @brief  Initializes the LCD.
00162   * @retval LCD state
00163   */
00164 uint8_t BSP_LCD_Init(void)
00165 {    
00166   /* Select the used LCD */
00167 
00168   /* The RK043FN48H LCD 480x272 is selected */
00169   /* Timing Configuration */
00170   hLtdcHandler.Init.HorizontalSync = (RK043FN48H_HSYNC - 1);
00171   hLtdcHandler.Init.VerticalSync = (RK043FN48H_VSYNC - 1);
00172   hLtdcHandler.Init.AccumulatedHBP = (RK043FN48H_HSYNC + RK043FN48H_HBP - 1);
00173   hLtdcHandler.Init.AccumulatedVBP = (RK043FN48H_VSYNC + RK043FN48H_VBP - 1);
00174   hLtdcHandler.Init.AccumulatedActiveH = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP - 1);
00175   hLtdcHandler.Init.AccumulatedActiveW = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP - 1);
00176   hLtdcHandler.Init.TotalHeigh = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP + RK043FN48H_VFP - 1);
00177   hLtdcHandler.Init.TotalWidth = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP + RK043FN48H_HFP - 1);
00178   
00179   /* LCD clock configuration */
00180   BSP_LCD_ClockConfig(&hLtdcHandler, NULL);
00181 
00182   /* Initialize the LCD pixel width and pixel height */
00183   hLtdcHandler.LayerCfg->ImageWidth  = RK043FN48H_WIDTH;
00184   hLtdcHandler.LayerCfg->ImageHeight = RK043FN48H_HEIGHT;
00185 
00186   /* Background value */
00187   hLtdcHandler.Init.Backcolor.Blue = 0;
00188   hLtdcHandler.Init.Backcolor.Green = 0;
00189   hLtdcHandler.Init.Backcolor.Red = 0;
00190   
00191   /* Polarity */
00192   hLtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL;
00193   hLtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL; 
00194   hLtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL;  
00195   hLtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
00196   hLtdcHandler.Instance = LTDC;
00197 
00198   if(HAL_LTDC_GetState(&hLtdcHandler) == HAL_LTDC_STATE_RESET)
00199   {
00200     /* Initialize the LCD Msp: this __weak function can be rewritten by the application */
00201     BSP_LCD_MspInit(&hLtdcHandler, NULL);
00202   }
00203   HAL_LTDC_Init(&hLtdcHandler);
00204 
00205   /* Assert display enable LCD_DISP pin */
00206   HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET);
00207 
00208   /* Assert backlight LCD_BL_CTRL pin */
00209   HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET);
00210 
00211 #if !defined(DATA_IN_ExtSDRAM)
00212   /* Initialize the SDRAM */
00213   BSP_SDRAM_Init();
00214 #endif
00215     
00216   /* Initialize the font */
00217   BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
00218   
00219   return LCD_OK;
00220 }
00221 
00222 /**
00223   * @brief  DeInitializes the LCD.
00224   * @retval LCD state
00225   */
00226 uint8_t BSP_LCD_DeInit(void)
00227 { 
00228   /* Initialize the hLtdcHandler Instance parameter */
00229   hLtdcHandler.Instance = LTDC;
00230 
00231  /* Disable LTDC block */
00232   __HAL_LTDC_DISABLE(&hLtdcHandler);
00233 
00234   /* DeInit the LTDC */
00235   HAL_LTDC_DeInit(&hLtdcHandler);
00236 
00237   /* DeInit the LTDC MSP : this __weak function can be rewritten by the application */
00238   BSP_LCD_MspDeInit(&hLtdcHandler, NULL);
00239 
00240   return LCD_OK;
00241 }
00242 
00243 /**
00244   * @brief  Gets the LCD X size.
00245   * @retval Used LCD X size
00246   */
00247 uint32_t BSP_LCD_GetXSize(void)
00248 {
00249   return hLtdcHandler.LayerCfg[ActiveLayer].ImageWidth;
00250 }
00251 
00252 /**
00253   * @brief  Gets the LCD Y size.
00254   * @retval Used LCD Y size
00255   */
00256 uint32_t BSP_LCD_GetYSize(void)
00257 {
00258   return hLtdcHandler.LayerCfg[ActiveLayer].ImageHeight;
00259 }
00260 
00261 /**
00262   * @brief  Set the LCD X size.
00263   * @param  imageWidthPixels : image width in pixels unit
00264   * @retval None
00265   */
00266 void BSP_LCD_SetXSize(uint32_t imageWidthPixels)
00267 {
00268   hLtdcHandler.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels;
00269 }
00270 
00271 /**
00272   * @brief  Set the LCD Y size.
00273   * @param  imageHeightPixels : image height in lines unit
00274   * @retval None
00275   */
00276 void BSP_LCD_SetYSize(uint32_t imageHeightPixels)
00277 {
00278   hLtdcHandler.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels;
00279 }
00280 
00281 /**
00282   * @brief  Initializes the LCD layer in ARGB8888 format (32 bits per pixel).
00283   * @param  LayerIndex: Layer foreground or background
00284   * @param  FB_Address: Layer frame buffer
00285   * @retval None
00286   */
00287 void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address)
00288 {     
00289   LCD_LayerCfgTypeDef  layer_cfg;
00290 
00291   /* Layer Init */
00292   layer_cfg.WindowX0 = 0;
00293   layer_cfg.WindowX1 = BSP_LCD_GetXSize();
00294   layer_cfg.WindowY0 = 0;
00295   layer_cfg.WindowY1 = BSP_LCD_GetYSize(); 
00296   layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
00297   layer_cfg.FBStartAdress = FB_Address;
00298   layer_cfg.Alpha = 255;
00299   layer_cfg.Alpha0 = 0;
00300   layer_cfg.Backcolor.Blue = 0;
00301   layer_cfg.Backcolor.Green = 0;
00302   layer_cfg.Backcolor.Red = 0;
00303   layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
00304   layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
00305   layer_cfg.ImageWidth = BSP_LCD_GetXSize();
00306   layer_cfg.ImageHeight = BSP_LCD_GetYSize();
00307   
00308   HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, LayerIndex); 
00309 
00310   DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE;
00311   DrawProp[LayerIndex].pFont     = &Font24;
00312   DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; 
00313 }
00314 
00315 /**
00316   * @brief  Initializes the LCD layer in RGB565 format (16 bits per pixel).
00317   * @param  LayerIndex: Layer foreground or background
00318   * @param  FB_Address: Layer frame buffer
00319   * @retval None
00320   */
00321 void BSP_LCD_LayerRgb565Init(uint16_t LayerIndex, uint32_t FB_Address)
00322 {     
00323   LCD_LayerCfgTypeDef  layer_cfg;
00324 
00325   /* Layer Init */
00326   layer_cfg.WindowX0 = 0;
00327   layer_cfg.WindowX1 = BSP_LCD_GetXSize();
00328   layer_cfg.WindowY0 = 0;
00329   layer_cfg.WindowY1 = BSP_LCD_GetYSize(); 
00330   layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
00331   layer_cfg.FBStartAdress = FB_Address;
00332   layer_cfg.Alpha = 255;
00333   layer_cfg.Alpha0 = 0;
00334   layer_cfg.Backcolor.Blue = 0;
00335   layer_cfg.Backcolor.Green = 0;
00336   layer_cfg.Backcolor.Red = 0;
00337   layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
00338   layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
00339   layer_cfg.ImageWidth = BSP_LCD_GetXSize();
00340   layer_cfg.ImageHeight = BSP_LCD_GetYSize();
00341   
00342   HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, LayerIndex); 
00343 
00344   DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE;
00345   DrawProp[LayerIndex].pFont     = &Font24;
00346   DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; 
00347 }
00348 
00349 /**
00350   * @brief  Selects the LCD Layer.
00351   * @param  LayerIndex: Layer foreground or background
00352   * @retval None
00353   */
00354 void BSP_LCD_SelectLayer(uint32_t LayerIndex)
00355 {
00356   ActiveLayer = LayerIndex;
00357 } 
00358 
00359 /**
00360   * @brief  Sets an LCD Layer visible
00361   * @param  LayerIndex: Visible Layer
00362   * @param  State: New state of the specified layer
00363   *          This parameter can be one of the following values:
00364   *            @arg  ENABLE
00365   *            @arg  DISABLE 
00366   * @retval None
00367   */
00368 void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State)
00369 {
00370   if(State == ENABLE)
00371   {
00372     __HAL_LTDC_LAYER_ENABLE(&hLtdcHandler, LayerIndex);
00373   }
00374   else
00375   {
00376     __HAL_LTDC_LAYER_DISABLE(&hLtdcHandler, LayerIndex);
00377   }
00378   __HAL_LTDC_RELOAD_CONFIG(&hLtdcHandler);
00379 } 
00380 
00381 /**
00382   * @brief  Sets an LCD Layer visible without reloading.
00383   * @param  LayerIndex: Visible Layer
00384   * @param  State: New state of the specified layer
00385   *          This parameter can be one of the following values:
00386   *            @arg  ENABLE
00387   *            @arg  DISABLE 
00388   * @retval None
00389   */
00390 void BSP_LCD_SetLayerVisible_NoReload(uint32_t LayerIndex, FunctionalState State)
00391 {
00392   if(State == ENABLE)
00393   {
00394     __HAL_LTDC_LAYER_ENABLE(&hLtdcHandler, LayerIndex);
00395   }
00396   else
00397   {
00398     __HAL_LTDC_LAYER_DISABLE(&hLtdcHandler, LayerIndex);
00399   }
00400   /* Do not Sets the Reload  */
00401 } 
00402 
00403 /**
00404   * @brief  Configures the transparency.
00405   * @param  LayerIndex: Layer foreground or background.
00406   * @param  Transparency: Transparency
00407   *           This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF 
00408   * @retval None
00409   */
00410 void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency)
00411 {    
00412   HAL_LTDC_SetAlpha(&hLtdcHandler, Transparency, LayerIndex);
00413 }
00414 
00415 /**
00416   * @brief  Configures the transparency without reloading.
00417   * @param  LayerIndex: Layer foreground or background.
00418   * @param  Transparency: Transparency
00419   *           This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF 
00420   * @retval None
00421   */
00422 void BSP_LCD_SetTransparency_NoReload(uint32_t LayerIndex, uint8_t Transparency)
00423 {    
00424   HAL_LTDC_SetAlpha_NoReload(&hLtdcHandler, Transparency, LayerIndex);
00425 }
00426 
00427 /**
00428   * @brief  Sets an LCD layer frame buffer address.
00429   * @param  LayerIndex: Layer foreground or background
00430   * @param  Address: New LCD frame buffer value      
00431   * @retval None
00432   */
00433 void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address)
00434 {
00435   HAL_LTDC_SetAddress(&hLtdcHandler, Address, LayerIndex);
00436 }
00437 
00438 /**
00439   * @brief  Sets an LCD layer frame buffer address without reloading.
00440   * @param  LayerIndex: Layer foreground or background
00441   * @param  Address: New LCD frame buffer value      
00442   * @retval None
00443   */
00444 void BSP_LCD_SetLayerAddress_NoReload(uint32_t LayerIndex, uint32_t Address)
00445 {
00446   HAL_LTDC_SetAddress_NoReload(&hLtdcHandler, Address, LayerIndex);
00447 }
00448 
00449 /**
00450   * @brief  Sets display window.
00451   * @param  LayerIndex: Layer index
00452   * @param  Xpos: LCD X position
00453   * @param  Ypos: LCD Y position
00454   * @param  Width: LCD window width
00455   * @param  Height: LCD window height  
00456   * @retval None
00457   */
00458 void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
00459 {
00460   /* Reconfigure the layer size */
00461   HAL_LTDC_SetWindowSize(&hLtdcHandler, Width, Height, LayerIndex);
00462   
00463   /* Reconfigure the layer position */
00464   HAL_LTDC_SetWindowPosition(&hLtdcHandler, Xpos, Ypos, LayerIndex); 
00465 }
00466 
00467 /**
00468   * @brief  Sets display window without reloading.
00469   * @param  LayerIndex: Layer index
00470   * @param  Xpos: LCD X position
00471   * @param  Ypos: LCD Y position
00472   * @param  Width: LCD window width
00473   * @param  Height: LCD window height  
00474   * @retval None
00475   */
00476 void BSP_LCD_SetLayerWindow_NoReload(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
00477 {
00478   /* Reconfigure the layer size */
00479   HAL_LTDC_SetWindowSize_NoReload(&hLtdcHandler, Width, Height, LayerIndex);
00480   
00481   /* Reconfigure the layer position */
00482   HAL_LTDC_SetWindowPosition_NoReload(&hLtdcHandler, Xpos, Ypos, LayerIndex); 
00483 }
00484 
00485 /**
00486   * @brief  Configures and sets the color keying.
00487   * @param  LayerIndex: Layer foreground or background
00488   * @param  RGBValue: Color reference
00489   * @retval None
00490   */
00491 void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue)
00492 {  
00493   /* Configure and Enable the color Keying for LCD Layer */
00494   HAL_LTDC_ConfigColorKeying(&hLtdcHandler, RGBValue, LayerIndex);
00495   HAL_LTDC_EnableColorKeying(&hLtdcHandler, LayerIndex);
00496 }
00497 
00498 /**
00499   * @brief  Configures and sets the color keying without reloading.
00500   * @param  LayerIndex: Layer foreground or background
00501   * @param  RGBValue: Color reference
00502   * @retval None
00503   */
00504 void BSP_LCD_SetColorKeying_NoReload(uint32_t LayerIndex, uint32_t RGBValue)
00505 {  
00506   /* Configure and Enable the color Keying for LCD Layer */
00507   HAL_LTDC_ConfigColorKeying_NoReload(&hLtdcHandler, RGBValue, LayerIndex);
00508   HAL_LTDC_EnableColorKeying_NoReload(&hLtdcHandler, LayerIndex);
00509 }
00510 
00511 /**
00512   * @brief  Disables the color keying.
00513   * @param  LayerIndex: Layer foreground or background
00514   * @retval None
00515   */
00516 void BSP_LCD_ResetColorKeying(uint32_t LayerIndex)
00517 {   
00518   /* Disable the color Keying for LCD Layer */
00519   HAL_LTDC_DisableColorKeying(&hLtdcHandler, LayerIndex);
00520 }
00521 
00522 /**
00523   * @brief  Disables the color keying without reloading.
00524   * @param  LayerIndex: Layer foreground or background
00525   * @retval None
00526   */
00527 void BSP_LCD_ResetColorKeying_NoReload(uint32_t LayerIndex)
00528 {   
00529   /* Disable the color Keying for LCD Layer */
00530   HAL_LTDC_DisableColorKeying_NoReload(&hLtdcHandler, LayerIndex);
00531 }
00532 
00533 /**
00534   * @brief  Disables the color keying without reloading.
00535   * @param  ReloadType: can be one of the following values 
00536   *         - LCD_RELOAD_IMMEDIATE 
00537   *         - LCD_RELOAD_VERTICAL_BLANKING
00538   * @retval None
00539   */
00540 void BSP_LCD_Reload(uint32_t ReloadType)
00541 {
00542   HAL_LTDC_Reload (&hLtdcHandler, ReloadType);
00543 }
00544 
00545 /**
00546   * @brief  Sets the LCD text color.
00547   * @param  Color: Text color code ARGB(8-8-8-8)
00548   * @retval None
00549   */
00550 void BSP_LCD_SetTextColor(uint32_t Color)
00551 {
00552   DrawProp[ActiveLayer].TextColor = Color;
00553 }
00554 
00555 /**
00556   * @brief  Gets the LCD text color.
00557   * @retval Used text color.
00558   */
00559 uint32_t BSP_LCD_GetTextColor(void)
00560 {
00561   return DrawProp[ActiveLayer].TextColor;
00562 }
00563 
00564 /**
00565   * @brief  Sets the LCD background color.
00566   * @param  Color: Layer background color code ARGB(8-8-8-8)
00567   * @retval None
00568   */
00569 void BSP_LCD_SetBackColor(uint32_t Color)
00570 {
00571   DrawProp[ActiveLayer].BackColor = Color;
00572 }
00573 
00574 /**
00575   * @brief  Gets the LCD background color.
00576   * @retval Used background colour
00577   */
00578 uint32_t BSP_LCD_GetBackColor(void)
00579 {
00580   return DrawProp[ActiveLayer].BackColor;
00581 }
00582 
00583 /**
00584   * @brief  Sets the LCD text font.
00585   * @param  fonts: Layer font to be used
00586   * @retval None
00587   */
00588 void BSP_LCD_SetFont(sFONT *fonts)
00589 {
00590   DrawProp[ActiveLayer].pFont = fonts;
00591 }
00592 
00593 /**
00594   * @brief  Gets the LCD text font.
00595   * @retval Used layer font
00596   */
00597 sFONT *BSP_LCD_GetFont(void)
00598 {
00599   return DrawProp[ActiveLayer].pFont;
00600 }
00601 
00602 /**
00603   * @brief  Reads an LCD pixel.
00604   * @param  Xpos: X position 
00605   * @param  Ypos: Y position 
00606   * @retval RGB pixel color
00607   */
00608 uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
00609 {
00610   uint32_t ret = 0;
00611   
00612   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
00613   {
00614     /* Read data value from SDRAM memory */
00615     ret = *(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos)));
00616   }
00617   else if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
00618   {
00619     /* Read data value from SDRAM memory */
00620     ret = (*(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF);
00621   }
00622   else if((hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
00623           (hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
00624           (hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88))  
00625   {
00626     /* Read data value from SDRAM memory */
00627     ret = *(__IO uint16_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));    
00628   }
00629   else
00630   {
00631     /* Read data value from SDRAM memory */
00632     ret = *(__IO uint8_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));    
00633   }
00634   
00635   return ret;
00636 }
00637 
00638 /**
00639   * @brief  Clears the hole LCD.
00640   * @param  Color: Color of the background
00641   * @retval None
00642   */
00643 void BSP_LCD_Clear(uint32_t Color)
00644 { 
00645   /* Clear the LCD */ 
00646   LL_FillBuffer(ActiveLayer, (uint32_t *)(hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color);
00647 }
00648 
00649 /**
00650   * @brief  Clears the selected line.
00651   * @param  Line: Line to be cleared
00652   * @retval None
00653   */
00654 void BSP_LCD_ClearStringLine(uint32_t Line)
00655 {
00656   uint32_t color_backup = DrawProp[ActiveLayer].TextColor;
00657   DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor;
00658   
00659   /* Draw rectangle with background color */
00660   BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height);
00661   
00662   DrawProp[ActiveLayer].TextColor = color_backup;
00663   BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);  
00664 }
00665 
00666 /**
00667   * @brief  Displays one character.
00668   * @param  Xpos: Start column address
00669   * @param  Ypos: Line where to display the character shape.
00670   * @param  Ascii: Character ascii code
00671   *           This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E 
00672   * @retval None
00673   */
00674 void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
00675 {
00676   DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\
00677     DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]);
00678 }
00679 
00680 /**
00681   * @brief  Displays characters on the LCD.
00682   * @param  Xpos: X position (in pixel)
00683   * @param  Ypos: Y position (in pixel)   
00684   * @param  Text: Pointer to string to display on LCD
00685   * @param  Mode: Display mode
00686   *          This parameter can be one of the following values:
00687   *            @arg  CENTER_MODE
00688   *            @arg  RIGHT_MODE
00689   *            @arg  LEFT_MODE   
00690   * @retval None
00691   */
00692 void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
00693 {
00694   uint16_t ref_column = 1, i = 0;
00695   uint32_t size = 0, xsize = 0; 
00696   uint8_t  *ptr = Text;
00697   
00698   /* Get the text size */
00699   while (*ptr++) size ++ ;
00700   
00701   /* Characters number per line */
00702   xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width);
00703   
00704   switch (Mode)
00705   {
00706   case CENTER_MODE:
00707     {
00708       ref_column = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2;
00709       break;
00710     }
00711   case LEFT_MODE:
00712     {
00713       ref_column = Xpos;
00714       break;
00715     }
00716   case RIGHT_MODE:
00717     {
00718       ref_column = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width);
00719       break;
00720     }    
00721   default:
00722     {
00723       ref_column = Xpos;
00724       break;
00725     }
00726   }
00727   
00728   /* Check that the Start column is located in the screen */
00729   if ((ref_column < 1) || (ref_column >= 0x8000))
00730   {
00731     ref_column = 1;
00732   }
00733 
00734   /* Send the string character by character on LCD */
00735   while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width))
00736   {
00737     /* Display one character on LCD */
00738     BSP_LCD_DisplayChar(ref_column, Ypos, *Text);
00739     /* Decrement the column position by 16 */
00740     ref_column += DrawProp[ActiveLayer].pFont->Width;
00741     /* Point on the next character */
00742     Text++;
00743     i++;
00744   }  
00745 }
00746 
00747 /**
00748   * @brief  Displays a maximum of 60 characters on the LCD.
00749   * @param  Line: Line where to display the character shape
00750   * @param  ptr: Pointer to string to display on LCD
00751   * @retval None
00752   */
00753 void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
00754 {  
00755   BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE);
00756 }
00757 
00758 /**
00759   * @brief  Draws an horizontal line.
00760   * @param  Xpos: X position
00761   * @param  Ypos: Y position
00762   * @param  Length: Line length
00763   * @retval None
00764   */
00765 void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
00766 {
00767   uint32_t  Xaddress = 0;
00768   
00769   /* Get the line address */
00770   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
00771   { /* RGB565 format */
00772     Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos);
00773   }
00774   else
00775   { /* ARGB8888 format */
00776     Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
00777   }
00778   
00779   /* Write line */
00780   LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor);
00781 }
00782 
00783 /**
00784   * @brief  Draws a vertical line.
00785   * @param  Xpos: X position
00786   * @param  Ypos: Y position
00787   * @param  Length: Line length
00788   * @retval None
00789   */
00790 void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
00791 {
00792   uint32_t  Xaddress = 0;
00793   
00794   /* Get the line address */
00795   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
00796   { /* RGB565 format */
00797     Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos);
00798   }
00799   else
00800   { /* ARGB8888 format */
00801     Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
00802   }
00803   
00804   /* Write line */
00805   LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor);
00806 }
00807 
00808 /**
00809   * @brief  Draws an uni-line (between two points).
00810   * @param  x1: Point 1 X position
00811   * @param  y1: Point 1 Y position
00812   * @param  x2: Point 2 X position
00813   * @param  y2: Point 2 Y position
00814   * @retval None
00815   */
00816 void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
00817 {
00818   int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, 
00819   yinc1 = 0, yinc2 = 0, den = 0, num = 0, num_add = 0, num_pixels = 0, 
00820   curpixel = 0;
00821   
00822   deltax = ABS(x2 - x1);        /* The difference between the x's */
00823   deltay = ABS(y2 - y1);        /* The difference between the y's */
00824   x = x1;                       /* Start x off at the first pixel */
00825   y = y1;                       /* Start y off at the first pixel */
00826   
00827   if (x2 >= x1)                 /* The x-values are increasing */
00828   {
00829     xinc1 = 1;
00830     xinc2 = 1;
00831   }
00832   else                          /* The x-values are decreasing */
00833   {
00834     xinc1 = -1;
00835     xinc2 = -1;
00836   }
00837   
00838   if (y2 >= y1)                 /* The y-values are increasing */
00839   {
00840     yinc1 = 1;
00841     yinc2 = 1;
00842   }
00843   else                          /* The y-values are decreasing */
00844   {
00845     yinc1 = -1;
00846     yinc2 = -1;
00847   }
00848   
00849   if (deltax >= deltay)         /* There is at least one x-value for every y-value */
00850   {
00851     xinc1 = 0;                  /* Don't change the x when numerator >= denominator */
00852     yinc2 = 0;                  /* Don't change the y for every iteration */
00853     den = deltax;
00854     num = deltax / 2;
00855     num_add = deltay;
00856     num_pixels = deltax;         /* There are more x-values than y-values */
00857   }
00858   else                          /* There is at least one y-value for every x-value */
00859   {
00860     xinc2 = 0;                  /* Don't change the x for every iteration */
00861     yinc1 = 0;                  /* Don't change the y when numerator >= denominator */
00862     den = deltay;
00863     num = deltay / 2;
00864     num_add = deltax;
00865     num_pixels = deltay;         /* There are more y-values than x-values */
00866   }
00867   
00868   for (curpixel = 0; curpixel <= num_pixels; curpixel++)
00869   {
00870     BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor);   /* Draw the current pixel */
00871     num += num_add;                            /* Increase the numerator by the top of the fraction */
00872     if (num >= den)                           /* Check if numerator >= denominator */
00873     {
00874       num -= den;                             /* Calculate the new numerator value */
00875       x += xinc1;                             /* Change the x as appropriate */
00876       y += yinc1;                             /* Change the y as appropriate */
00877     }
00878     x += xinc2;                               /* Change the x as appropriate */
00879     y += yinc2;                               /* Change the y as appropriate */
00880   }
00881 }
00882 
00883 /**
00884   * @brief  Draws a rectangle.
00885   * @param  Xpos: X position
00886   * @param  Ypos: Y position
00887   * @param  Width: Rectangle width  
00888   * @param  Height: Rectangle height
00889   * @retval None
00890   */
00891 void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
00892 {
00893   /* Draw horizontal lines */
00894   BSP_LCD_DrawHLine(Xpos, Ypos, Width);
00895   BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width);
00896   
00897   /* Draw vertical lines */
00898   BSP_LCD_DrawVLine(Xpos, Ypos, Height);
00899   BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height);
00900 }
00901 
00902 /**
00903   * @brief  Draws a circle.
00904   * @param  Xpos: X position
00905   * @param  Ypos: Y position
00906   * @param  Radius: Circle radius
00907   * @retval None
00908   */
00909 void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
00910 {
00911   int32_t   decision;    /* Decision Variable */ 
00912   uint32_t  current_x;   /* Current X Value */
00913   uint32_t  current_y;   /* Current Y Value */
00914   
00915   decision = 3 - (Radius << 1);
00916   current_x = 0;
00917   current_y = Radius;
00918   
00919   while (current_x <= current_y)
00920   {
00921     BSP_LCD_DrawPixel((Xpos + current_x), (Ypos - current_y), DrawProp[ActiveLayer].TextColor);
00922     
00923     BSP_LCD_DrawPixel((Xpos - current_x), (Ypos - current_y), DrawProp[ActiveLayer].TextColor);
00924     
00925     BSP_LCD_DrawPixel((Xpos + current_y), (Ypos - current_x), DrawProp[ActiveLayer].TextColor);
00926     
00927     BSP_LCD_DrawPixel((Xpos - current_y), (Ypos - current_x), DrawProp[ActiveLayer].TextColor);
00928     
00929     BSP_LCD_DrawPixel((Xpos + current_x), (Ypos + current_y), DrawProp[ActiveLayer].TextColor);
00930     
00931     BSP_LCD_DrawPixel((Xpos - current_x), (Ypos + current_y), DrawProp[ActiveLayer].TextColor);
00932     
00933     BSP_LCD_DrawPixel((Xpos + current_y), (Ypos + current_x), DrawProp[ActiveLayer].TextColor);
00934     
00935     BSP_LCD_DrawPixel((Xpos - current_y), (Ypos + current_x), DrawProp[ActiveLayer].TextColor);
00936     
00937     if (decision < 0)
00938     { 
00939       decision += (current_x << 2) + 6;
00940     }
00941     else
00942     {
00943       decision += ((current_x - current_y) << 2) + 10;
00944       current_y--;
00945     }
00946     current_x++;
00947   } 
00948 }
00949 
00950 /**
00951   * @brief  Draws an poly-line (between many points).
00952   * @param  Points: Pointer to the points array
00953   * @param  PointCount: Number of points
00954   * @retval None
00955   */
00956 void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount)
00957 {
00958   int16_t x = 0, y = 0;
00959   
00960   if(PointCount < 2)
00961   {
00962     return;
00963   }
00964   
00965   BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
00966   
00967   while(--PointCount)
00968   {
00969     x = Points->X;
00970     y = Points->Y;
00971     Points++;
00972     BSP_LCD_DrawLine(x, y, Points->X, Points->Y);
00973   }
00974 }
00975 
00976 /**
00977   * @brief  Draws an ellipse on LCD.
00978   * @param  Xpos: X position
00979   * @param  Ypos: Y position
00980   * @param  XRadius: Ellipse X radius
00981   * @param  YRadius: Ellipse Y radius
00982   * @retval None
00983   */
00984 void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
00985 {
00986   int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
00987   float k = 0, rad1 = 0, rad2 = 0;
00988   
00989   rad1 = XRadius;
00990   rad2 = YRadius;
00991   
00992   k = (float)(rad2/rad1);  
00993   
00994   do { 
00995     BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
00996     BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
00997     BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
00998     BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor);      
00999     
01000     e2 = err;
01001     if (e2 <= x) {
01002       err += ++x*2+1;
01003       if (-y == x && e2 <= y) e2 = 0;
01004     }
01005     if (e2 > y) err += ++y*2+1;     
01006   }
01007   while (y <= 0);
01008 }
01009 
01010 /**
01011   * @brief  Draws a pixel on LCD.
01012   * @param  Xpos: X position
01013   * @param  Ypos: Y position
01014   * @param  RGB_Code: Pixel color in ARGB mode (8-8-8-8)
01015   * @retval None
01016   */
01017 void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
01018 {
01019   /* Write data value to all SDRAM memory */
01020   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
01021   { /* RGB565 format */
01022     *(__IO uint16_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) = (uint16_t)RGB_Code;
01023   }
01024   else
01025   { /* ARGB8888 format */
01026     *(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code;
01027   }
01028 }
01029 
01030 /**
01031   * @brief  Draws a bitmap picture loaded in the internal Flash in ARGB888 format (32 bits per pixel).
01032   * @param  Xpos: Bmp X position in the LCD
01033   * @param  Ypos: Bmp Y position in the LCD
01034   * @param  pbmp: Pointer to Bmp picture address in the internal Flash
01035   * @retval None
01036   */
01037 void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
01038 {
01039   uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
01040   uint32_t address;
01041   uint32_t input_color_mode = 0;
01042   
01043   /* Get bitmap data address offset */
01044   index = pbmp[10] + (pbmp[11] << 8) + (pbmp[12] << 16)  + (pbmp[13] << 24);
01045 
01046   /* Read bitmap width */
01047   width = pbmp[18] + (pbmp[19] << 8) + (pbmp[20] << 16)  + (pbmp[21] << 24);
01048 
01049   /* Read bitmap height */
01050   height = pbmp[22] + (pbmp[23] << 8) + (pbmp[24] << 16)  + (pbmp[25] << 24);
01051 
01052   /* Read bit/pixel */
01053   bit_pixel = pbmp[28] + (pbmp[29] << 8);  
01054   
01055   /* Set the address */
01056   address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
01057   
01058   /* Get the layer pixel format */    
01059   if ((bit_pixel/8) == 4)
01060   {
01061     input_color_mode = CM_ARGB8888;
01062   }
01063   else if ((bit_pixel/8) == 2)
01064   {
01065     input_color_mode = CM_RGB565;   
01066   }
01067   else 
01068   {
01069     input_color_mode = CM_RGB888;
01070   }
01071   
01072   /* Bypass the bitmap header */
01073   pbmp += (index + (width * (height - 1) * (bit_pixel/8)));  
01074   
01075   /* Convert picture to ARGB8888 pixel format */
01076   for(index=0; index < height; index++)
01077   {
01078     /* Pixel format conversion */
01079     LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode);
01080     
01081     /* Increment the source and destination buffers */
01082     address+=  (BSP_LCD_GetXSize()*4);
01083     pbmp -= width*(bit_pixel/8);
01084   } 
01085 }
01086 
01087 /**
01088   * @brief  Draws a full rectangle.
01089   * @param  Xpos: X position
01090   * @param  Ypos: Y position
01091   * @param  Width: Rectangle width  
01092   * @param  Height: Rectangle height
01093   * @retval None
01094   */
01095 void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
01096 {
01097   uint32_t  x_address = 0;
01098   
01099   /* Set the text color */
01100   BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
01101   
01102   /* Get the rectangle start address */
01103   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
01104   { /* RGB565 format */
01105     x_address = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos);
01106   }
01107   else
01108   { /* ARGB8888 format */
01109     x_address = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
01110   }
01111   /* Fill the rectangle */
01112   LL_FillBuffer(ActiveLayer, (uint32_t *)x_address, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor);
01113 }
01114 
01115 /**
01116   * @brief  Draws a full circle.
01117   * @param  Xpos: X position
01118   * @param  Ypos: Y position
01119   * @param  Radius: Circle radius
01120   * @retval None
01121   */
01122 void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
01123 {
01124   int32_t  decision;     /* Decision Variable */ 
01125   uint32_t  current_x;   /* Current X Value */
01126   uint32_t  current_y;   /* Current Y Value */
01127   
01128   decision = 3 - (Radius << 1);
01129   
01130   current_x = 0;
01131   current_y = Radius;
01132   
01133   BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
01134   
01135   while (current_x <= current_y)
01136   {
01137     if(current_y > 0) 
01138     {
01139       BSP_LCD_DrawHLine(Xpos - current_y, Ypos + current_x, 2*current_y);
01140       BSP_LCD_DrawHLine(Xpos - current_y, Ypos - current_x, 2*current_y);
01141     }
01142     
01143     if(current_x > 0) 
01144     {
01145       BSP_LCD_DrawHLine(Xpos - current_x, Ypos - current_y, 2*current_x);
01146       BSP_LCD_DrawHLine(Xpos - current_x, Ypos + current_y, 2*current_x);
01147     }
01148     if (decision < 0)
01149     { 
01150       decision += (current_x << 2) + 6;
01151     }
01152     else
01153     {
01154       decision += ((current_x - current_y) << 2) + 10;
01155       current_y--;
01156     }
01157     current_x++;
01158   }
01159   
01160   BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
01161   BSP_LCD_DrawCircle(Xpos, Ypos, Radius);
01162 }
01163 
01164 /**
01165   * @brief  Draws a full poly-line (between many points).
01166   * @param  Points: Pointer to the points array
01167   * @param  PointCount: Number of points
01168   * @retval None
01169   */
01170 void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount)
01171 {
01172   int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0;
01173   uint16_t  image_left = 0, image_right = 0, image_top = 0, image_bottom = 0;
01174   
01175   image_left = image_right = Points->X;
01176   image_top= image_bottom = Points->Y;
01177   
01178   for(counter = 1; counter < PointCount; counter++)
01179   {
01180     pixelX = POLY_X(counter);
01181     if(pixelX < image_left)
01182     {
01183       image_left = pixelX;
01184     }
01185     if(pixelX > image_right)
01186     {
01187       image_right = pixelX;
01188     }
01189     
01190     pixelY = POLY_Y(counter);
01191     if(pixelY < image_top)
01192     { 
01193       image_top = pixelY;
01194     }
01195     if(pixelY > image_bottom)
01196     {
01197       image_bottom = pixelY;
01198     }
01199   }  
01200   
01201   if(PointCount < 2)
01202   {
01203     return;
01204   }
01205   
01206   X_center = (image_left + image_right)/2;
01207   Y_center = (image_bottom + image_top)/2;
01208   
01209   X_first = Points->X;
01210   Y_first = Points->Y;
01211   
01212   while(--PointCount)
01213   {
01214     X = Points->X;
01215     Y = Points->Y;
01216     Points++;
01217     X2 = Points->X;
01218     Y2 = Points->Y;    
01219     
01220     FillTriangle(X, X2, X_center, Y, Y2, Y_center);
01221     FillTriangle(X, X_center, X2, Y, Y_center, Y2);
01222     FillTriangle(X_center, X2, X, Y_center, Y2, Y);   
01223   }
01224   
01225   FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center);
01226   FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2);
01227   FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first);   
01228 }
01229 
01230 /**
01231   * @brief  Draws a full ellipse.
01232   * @param  Xpos: X position
01233   * @param  Ypos: Y position
01234   * @param  XRadius: Ellipse X radius
01235   * @param  YRadius: Ellipse Y radius  
01236   * @retval None
01237   */
01238 void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
01239 {
01240   int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
01241   float k = 0, rad1 = 0, rad2 = 0;
01242   
01243   rad1 = XRadius;
01244   rad2 = YRadius;
01245   
01246   k = (float)(rad2/rad1);
01247   
01248   do 
01249   {       
01250     BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos+y), (2*(uint16_t)(x/k) + 1));
01251     BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos-y), (2*(uint16_t)(x/k) + 1));
01252     
01253     e2 = err;
01254     if (e2 <= x) 
01255     {
01256       err += ++x*2+1;
01257       if (-y == x && e2 <= y) e2 = 0;
01258     }
01259     if (e2 > y) err += ++y*2+1;
01260   }
01261   while (y <= 0);
01262 }
01263 
01264 /**
01265   * @brief  Enables the display.
01266   * @retval None
01267   */
01268 void BSP_LCD_DisplayOn(void)
01269 {
01270   /* Display On */
01271   __HAL_LTDC_ENABLE(&hLtdcHandler);
01272   HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET);        /* Assert LCD_DISP pin */
01273   HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET);  /* Assert LCD_BL_CTRL pin */
01274 }
01275 
01276 /**
01277   * @brief  Disables the display.
01278   * @retval None
01279   */
01280 void BSP_LCD_DisplayOff(void)
01281 {
01282   /* Display Off */
01283   __HAL_LTDC_DISABLE(&hLtdcHandler);
01284   HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_RESET);      /* De-assert LCD_DISP pin */
01285   HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_RESET);/* De-assert LCD_BL_CTRL pin */
01286 }
01287 
01288 /**
01289   * @brief  Initializes the LTDC MSP.
01290   * @param  hltdc: LTDC handle
01291   * @param  Params
01292   * @retval None
01293   */
01294 __weak void BSP_LCD_MspInit(LTDC_HandleTypeDef *hltdc, void *Params)
01295 {
01296   GPIO_InitTypeDef gpio_init_structure;
01297   
01298   /* Enable the LTDC and DMA2D clocks */
01299   __HAL_RCC_LTDC_CLK_ENABLE();
01300   __HAL_RCC_DMA2D_CLK_ENABLE();
01301   
01302   /* Enable GPIOs clock */
01303   __HAL_RCC_GPIOE_CLK_ENABLE();
01304   __HAL_RCC_GPIOG_CLK_ENABLE();
01305   __HAL_RCC_GPIOI_CLK_ENABLE();
01306   __HAL_RCC_GPIOJ_CLK_ENABLE();
01307   __HAL_RCC_GPIOK_CLK_ENABLE();
01308   LCD_DISP_GPIO_CLK_ENABLE();
01309   LCD_BL_CTRL_GPIO_CLK_ENABLE();
01310 
01311   /*** LTDC Pins configuration ***/
01312   /* GPIOE configuration */
01313   gpio_init_structure.Pin       = GPIO_PIN_4;
01314   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
01315   gpio_init_structure.Pull      = GPIO_NOPULL;
01316   gpio_init_structure.Speed     = GPIO_SPEED_FAST;
01317   gpio_init_structure.Alternate = GPIO_AF14_LTDC;  
01318   HAL_GPIO_Init(GPIOE, &gpio_init_structure);
01319 
01320   /* GPIOG configuration */
01321   gpio_init_structure.Pin       = GPIO_PIN_12;
01322   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
01323   gpio_init_structure.Alternate = GPIO_AF9_LTDC;
01324   HAL_GPIO_Init(GPIOG, &gpio_init_structure);
01325 
01326   /* GPIOI LTDC alternate configuration */
01327   gpio_init_structure.Pin       = GPIO_PIN_9 | GPIO_PIN_10 | \
01328                                   GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
01329   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
01330   gpio_init_structure.Alternate = GPIO_AF14_LTDC;
01331   HAL_GPIO_Init(GPIOI, &gpio_init_structure);
01332 
01333   /* GPIOJ configuration */  
01334   gpio_init_structure.Pin       = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \
01335                                   GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \
01336                                   GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \
01337                                   GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
01338   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
01339   gpio_init_structure.Alternate = GPIO_AF14_LTDC;
01340   HAL_GPIO_Init(GPIOJ, &gpio_init_structure);  
01341 
01342   /* GPIOK configuration */  
01343   gpio_init_structure.Pin       = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \
01344                                   GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
01345   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
01346   gpio_init_structure.Alternate = GPIO_AF14_LTDC;
01347   HAL_GPIO_Init(GPIOK, &gpio_init_structure);
01348 
01349   /* LCD_DISP GPIO configuration */
01350   gpio_init_structure.Pin       = LCD_DISP_PIN;     /* LCD_DISP pin has to be manually controlled */
01351   gpio_init_structure.Mode      = GPIO_MODE_OUTPUT_PP;
01352   HAL_GPIO_Init(LCD_DISP_GPIO_PORT, &gpio_init_structure);
01353 
01354   /* LCD_BL_CTRL GPIO configuration */
01355   gpio_init_structure.Pin       = LCD_BL_CTRL_PIN;  /* LCD_BL_CTRL pin has to be manually controlled */
01356   gpio_init_structure.Mode      = GPIO_MODE_OUTPUT_PP;
01357   HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure);
01358 }
01359 
01360 /**
01361   * @brief  DeInitializes BSP_LCD MSP.
01362   * @param  hltdc: LTDC handle
01363   * @param  Params
01364   * @retval None
01365   */
01366 __weak void BSP_LCD_MspDeInit(LTDC_HandleTypeDef *hltdc, void *Params)
01367 {
01368   GPIO_InitTypeDef  gpio_init_structure;
01369 
01370   /* Disable LTDC block */
01371   __HAL_LTDC_DISABLE(hltdc);
01372 
01373   /* LTDC Pins deactivation */
01374 
01375   /* GPIOE deactivation */
01376   gpio_init_structure.Pin       = GPIO_PIN_4;
01377   HAL_GPIO_DeInit(GPIOE, gpio_init_structure.Pin);
01378 
01379   /* GPIOG deactivation */
01380   gpio_init_structure.Pin       = GPIO_PIN_12;
01381   HAL_GPIO_DeInit(GPIOG, gpio_init_structure.Pin);
01382 
01383   /* GPIOI deactivation */
01384   gpio_init_structure.Pin       = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_12 | \
01385                                   GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
01386   HAL_GPIO_DeInit(GPIOI, gpio_init_structure.Pin);
01387 
01388   /* GPIOJ deactivation */
01389   gpio_init_structure.Pin       = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \
01390                                   GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \
01391                                   GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \
01392                                   GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
01393   HAL_GPIO_DeInit(GPIOJ, gpio_init_structure.Pin);
01394 
01395   /* GPIOK deactivation */
01396   gpio_init_structure.Pin       = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \
01397                                   GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
01398   HAL_GPIO_DeInit(GPIOK, gpio_init_structure.Pin);
01399 
01400   /* Disable LTDC clock */
01401   __HAL_RCC_LTDC_CLK_DISABLE();
01402 
01403   /* GPIO pins clock can be shut down in the application
01404      by surcharging this __weak function */
01405 }
01406 
01407 /**
01408   * @brief  Clock Config.
01409   * @param  hltdc: LTDC handle
01410   * @param  Params
01411   * @note   This API is called by BSP_LCD_Init()
01412   *         Being __weak it can be overwritten by the application
01413   * @retval None
01414   */
01415 __weak void BSP_LCD_ClockConfig(LTDC_HandleTypeDef *hltdc, void *Params)
01416 {
01417   static RCC_PeriphCLKInitTypeDef  periph_clk_init_struct;
01418 
01419   /* RK043FN48H LCD clock configuration */
01420   /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
01421   /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
01422   /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */
01423   /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */
01424   periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
01425   periph_clk_init_struct.PLLSAI.PLLSAIN = 192;
01426   periph_clk_init_struct.PLLSAI.PLLSAIR = RK043FN48H_FREQUENCY_DIVIDER;
01427   periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
01428   HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct);
01429 }
01430 
01431 
01432 /*******************************************************************************
01433                             Static Functions
01434 *******************************************************************************/
01435 
01436 /**
01437   * @brief  Draws a character on LCD.
01438   * @param  Xpos: Line where to display the character shape
01439   * @param  Ypos: Start column address
01440   * @param  c: Pointer to the character data
01441   * @retval None
01442   */
01443 static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c)
01444 {
01445   uint32_t i = 0, j = 0;
01446   uint16_t height, width;
01447   uint8_t  offset;
01448   uint8_t  *pchar;
01449   uint32_t line;
01450   
01451   height = DrawProp[ActiveLayer].pFont->Height;
01452   width  = DrawProp[ActiveLayer].pFont->Width;
01453   
01454   offset =  8 *((width + 7)/8) -  width ;
01455   
01456   for(i = 0; i < height; i++)
01457   {
01458     pchar = ((uint8_t *)c + (width + 7)/8 * i);
01459     
01460     switch(((width + 7)/8))
01461     {
01462       
01463     case 1:
01464       line =  pchar[0];      
01465       break;
01466       
01467     case 2:
01468       line =  (pchar[0]<< 8) | pchar[1];      
01469       break;
01470       
01471     case 3:
01472     default:
01473       line =  (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];      
01474       break;
01475     } 
01476     
01477     for (j = 0; j < width; j++)
01478     {
01479       if(line & (1 << (width- j + offset- 1))) 
01480       {
01481         BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor);
01482       }
01483       else
01484       {
01485         BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor);
01486       } 
01487     }
01488     Ypos++;
01489   }
01490 }
01491 
01492 /**
01493   * @brief  Fills a triangle (between 3 points).
01494   * @param  x1: Point 1 X position
01495   * @param  y1: Point 1 Y position
01496   * @param  x2: Point 2 X position
01497   * @param  y2: Point 2 Y position
01498   * @param  x3: Point 3 X position
01499   * @param  y3: Point 3 Y position
01500   * @retval None
01501   */
01502 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
01503 { 
01504   int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, 
01505   yinc1 = 0, yinc2 = 0, den = 0, num = 0, num_add = 0, num_pixels = 0,
01506   curpixel = 0;
01507   
01508   deltax = ABS(x2 - x1);        /* The difference between the x's */
01509   deltay = ABS(y2 - y1);        /* The difference between the y's */
01510   x = x1;                       /* Start x off at the first pixel */
01511   y = y1;                       /* Start y off at the first pixel */
01512   
01513   if (x2 >= x1)                 /* The x-values are increasing */
01514   {
01515     xinc1 = 1;
01516     xinc2 = 1;
01517   }
01518   else                          /* The x-values are decreasing */
01519   {
01520     xinc1 = -1;
01521     xinc2 = -1;
01522   }
01523   
01524   if (y2 >= y1)                 /* The y-values are increasing */
01525   {
01526     yinc1 = 1;
01527     yinc2 = 1;
01528   }
01529   else                          /* The y-values are decreasing */
01530   {
01531     yinc1 = -1;
01532     yinc2 = -1;
01533   }
01534   
01535   if (deltax >= deltay)         /* There is at least one x-value for every y-value */
01536   {
01537     xinc1 = 0;                  /* Don't change the x when numerator >= denominator */
01538     yinc2 = 0;                  /* Don't change the y for every iteration */
01539     den = deltax;
01540     num = deltax / 2;
01541     num_add = deltay;
01542     num_pixels = deltax;         /* There are more x-values than y-values */
01543   }
01544   else                          /* There is at least one y-value for every x-value */
01545   {
01546     xinc2 = 0;                  /* Don't change the x for every iteration */
01547     yinc1 = 0;                  /* Don't change the y when numerator >= denominator */
01548     den = deltay;
01549     num = deltay / 2;
01550     num_add = deltax;
01551     num_pixels = deltay;         /* There are more y-values than x-values */
01552   }
01553   
01554   for (curpixel = 0; curpixel <= num_pixels; curpixel++)
01555   {
01556     BSP_LCD_DrawLine(x, y, x3, y3);
01557     
01558     num += num_add;              /* Increase the numerator by the top of the fraction */
01559     if (num >= den)             /* Check if numerator >= denominator */
01560     {
01561       num -= den;               /* Calculate the new numerator value */
01562       x += xinc1;               /* Change the x as appropriate */
01563       y += yinc1;               /* Change the y as appropriate */
01564     }
01565     x += xinc2;                 /* Change the x as appropriate */
01566     y += yinc2;                 /* Change the y as appropriate */
01567   } 
01568 }
01569 
01570 /**
01571   * @brief  Fills a buffer.
01572   * @param  LayerIndex: Layer index
01573   * @param  pDst: Pointer to destination buffer
01574   * @param  xSize: Buffer width
01575   * @param  ySize: Buffer height
01576   * @param  OffLine: Offset
01577   * @param  ColorIndex: Color index
01578   * @retval None
01579   */
01580 static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) 
01581 {
01582   /* Register to memory mode with ARGB8888 as color Mode */ 
01583   hDma2dHandler.Init.Mode         = DMA2D_R2M;
01584   if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
01585   { /* RGB565 format */ 
01586     hDma2dHandler.Init.ColorMode    = DMA2D_RGB565;
01587   }
01588   else
01589   { /* ARGB8888 format */
01590     hDma2dHandler.Init.ColorMode    = DMA2D_ARGB8888;
01591   }
01592   hDma2dHandler.Init.OutputOffset = OffLine;      
01593   
01594   hDma2dHandler.Instance = DMA2D;
01595   
01596   /* DMA2D Initialization */
01597   if(HAL_DMA2D_Init(&hDma2dHandler) == HAL_OK) 
01598   {
01599     if(HAL_DMA2D_ConfigLayer(&hDma2dHandler, LayerIndex) == HAL_OK) 
01600     {
01601       if (HAL_DMA2D_Start(&hDma2dHandler, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK)
01602       {
01603         /* Polling For DMA transfer */  
01604         HAL_DMA2D_PollForTransfer(&hDma2dHandler, 10);
01605       }
01606     }
01607   } 
01608 }
01609 
01610 /**
01611   * @brief  Converts a line to an ARGB8888 pixel format.
01612   * @param  pSrc: Pointer to source buffer
01613   * @param  pDst: Output color
01614   * @param  xSize: Buffer width
01615   * @param  ColorMode: Input color mode   
01616   * @retval None
01617   */
01618 static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode)
01619 {    
01620   /* Configure the DMA2D Mode, Color Mode and output offset */
01621   hDma2dHandler.Init.Mode         = DMA2D_M2M_PFC;
01622   hDma2dHandler.Init.ColorMode    = DMA2D_ARGB8888;
01623   hDma2dHandler.Init.OutputOffset = 0;     
01624   
01625   /* Foreground Configuration */
01626   hDma2dHandler.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
01627   hDma2dHandler.LayerCfg[1].InputAlpha = 0xFF;
01628   hDma2dHandler.LayerCfg[1].InputColorMode = ColorMode;
01629   hDma2dHandler.LayerCfg[1].InputOffset = 0;
01630   
01631   hDma2dHandler.Instance = DMA2D; 
01632   
01633   /* DMA2D Initialization */
01634   if(HAL_DMA2D_Init(&hDma2dHandler) == HAL_OK) 
01635   {
01636     if(HAL_DMA2D_ConfigLayer(&hDma2dHandler, 1) == HAL_OK) 
01637     {
01638       if (HAL_DMA2D_Start(&hDma2dHandler, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK)
01639       {
01640         /* Polling For DMA transfer */  
01641         HAL_DMA2D_PollForTransfer(&hDma2dHandler, 10);
01642       }
01643     }
01644   } 
01645 }
01646 
01647 /**
01648   * @}
01649   */
01650 
01651 /**
01652   * @}
01653   */
01654   
01655 /**
01656   * @}
01657   */
01658   
01659 /**
01660   * @}
01661   */        
01662 
01663 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/