Nenad Djalovic / BSP_DISCO_F469NIfdsf

Fork of BSP_DISCO_F469NI by ST

Committer:
bcostm
Date:
Fri Dec 18 07:32:01 2015 +0000
Revision:
0:0002c86c2220
Child:
1:9e4eb47092ed
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:0002c86c2220 1 /**
bcostm 0:0002c86c2220 2 ******************************************************************************
bcostm 0:0002c86c2220 3 * @file stm32469i_discovery_lcd.c
bcostm 0:0002c86c2220 4 * @author MCD Application Team
bcostm 0:0002c86c2220 5 * @version V1.0.1
bcostm 0:0002c86c2220 6 * @date 29-September-2015
bcostm 0:0002c86c2220 7 * @brief This file includes the driver for Liquid Crystal Display (LCD) module
bcostm 0:0002c86c2220 8 * mounted on STM32469I-Discovery evaluation board.
bcostm 0:0002c86c2220 9 ******************************************************************************
bcostm 0:0002c86c2220 10 * @attention
bcostm 0:0002c86c2220 11 *
bcostm 0:0002c86c2220 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bcostm 0:0002c86c2220 13 *
bcostm 0:0002c86c2220 14 * Redistribution and use in source and binary forms, with or without modification,
bcostm 0:0002c86c2220 15 * are permitted provided that the following conditions are met:
bcostm 0:0002c86c2220 16 * 1. Redistributions of source code must retain the above copyright notice,
bcostm 0:0002c86c2220 17 * this list of conditions and the following disclaimer.
bcostm 0:0002c86c2220 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 0:0002c86c2220 19 * this list of conditions and the following disclaimer in the documentation
bcostm 0:0002c86c2220 20 * and/or other materials provided with the distribution.
bcostm 0:0002c86c2220 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bcostm 0:0002c86c2220 22 * may be used to endorse or promote products derived from this software
bcostm 0:0002c86c2220 23 * without specific prior written permission.
bcostm 0:0002c86c2220 24 *
bcostm 0:0002c86c2220 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bcostm 0:0002c86c2220 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bcostm 0:0002c86c2220 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bcostm 0:0002c86c2220 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bcostm 0:0002c86c2220 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bcostm 0:0002c86c2220 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bcostm 0:0002c86c2220 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bcostm 0:0002c86c2220 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bcostm 0:0002c86c2220 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bcostm 0:0002c86c2220 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 0:0002c86c2220 35 *
bcostm 0:0002c86c2220 36 ******************************************************************************
bcostm 0:0002c86c2220 37 */
bcostm 0:0002c86c2220 38
bcostm 0:0002c86c2220 39 /* File Info: ------------------------------------------------------------------
bcostm 0:0002c86c2220 40 User NOTES
bcostm 0:0002c86c2220 41 1. How To use this driver:
bcostm 0:0002c86c2220 42 --------------------------
bcostm 0:0002c86c2220 43 - This driver is used to drive directly in video mode a LCD TFT using the DSI interface.
bcostm 0:0002c86c2220 44 The following IPs are implied : DSI Host IP block working
bcostm 0:0002c86c2220 45 in conjunction to the LTDC controller.
bcostm 0:0002c86c2220 46 - This driver is linked by construction to LCD KoD mounted on board MB1166.
bcostm 0:0002c86c2220 47
bcostm 0:0002c86c2220 48 2. Driver description:
bcostm 0:0002c86c2220 49 ---------------------
bcostm 0:0002c86c2220 50 + Initialization steps:
bcostm 0:0002c86c2220 51 o Initialize the LCD using the BSP_LCD_Init() function.
bcostm 0:0002c86c2220 52 o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
bcostm 0:0002c86c2220 53 o Enable the LCD display using the BSP_LCD_DisplayOn() function.
bcostm 0:0002c86c2220 54
bcostm 0:0002c86c2220 55 + Options
bcostm 0:0002c86c2220 56 o Configure and enable the color keying functionality using the
bcostm 0:0002c86c2220 57 BSP_LCD_SetColorKeying() function.
bcostm 0:0002c86c2220 58 o Modify in the fly the transparency and/or the frame buffer address
bcostm 0:0002c86c2220 59 using the following functions:
bcostm 0:0002c86c2220 60 - BSP_LCD_SetTransparency()
bcostm 0:0002c86c2220 61 - BSP_LCD_SetLayerAddress()
bcostm 0:0002c86c2220 62
bcostm 0:0002c86c2220 63 + Display on LCD
bcostm 0:0002c86c2220 64 o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string
bcostm 0:0002c86c2220 65 line using the BSP_LCD_ClearStringLine() function.
bcostm 0:0002c86c2220 66 o Display a character on the specified line and column using the BSP_LCD_DisplayChar()
bcostm 0:0002c86c2220 67 function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
bcostm 0:0002c86c2220 68 o Display a string line on the specified position (x,y in pixel) and align mode
bcostm 0:0002c86c2220 69 using the BSP_LCD_DisplayStringAtLine() function.
bcostm 0:0002c86c2220 70 o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
bcostm 0:0002c86c2220 71 on LCD using the available set of functions.
bcostm 0:0002c86c2220 72
bcostm 0:0002c86c2220 73 ------------------------------------------------------------------------------*/
bcostm 0:0002c86c2220 74
bcostm 0:0002c86c2220 75 /* Includes ------------------------------------------------------------------*/
bcostm 0:0002c86c2220 76 #include "stm32469i_discovery_lcd.h"
bcostm 0:0002c86c2220 77 #include "../Fonts/fonts.h"
bcostm 0:0002c86c2220 78 //#include "../../../Utilities/Fonts/font24.c"
bcostm 0:0002c86c2220 79 //#include "../../../Utilities/Fonts/font20.c"
bcostm 0:0002c86c2220 80 //#include "../../../Utilities/Fonts/font16.c"
bcostm 0:0002c86c2220 81 //#include "../../../Utilities/Fonts/font12.c"
bcostm 0:0002c86c2220 82 //#include "../../../Utilities/Fonts/font8.c"
bcostm 0:0002c86c2220 83
bcostm 0:0002c86c2220 84 /** @addtogroup BSP
bcostm 0:0002c86c2220 85 * @{
bcostm 0:0002c86c2220 86 */
bcostm 0:0002c86c2220 87
bcostm 0:0002c86c2220 88 /** @addtogroup STM32469I-Discovery
bcostm 0:0002c86c2220 89 * @{
bcostm 0:0002c86c2220 90 */
bcostm 0:0002c86c2220 91
bcostm 0:0002c86c2220 92 /** @addtogroup STM32469I-Discovery_LCD
bcostm 0:0002c86c2220 93 * @{
bcostm 0:0002c86c2220 94 */
bcostm 0:0002c86c2220 95
bcostm 0:0002c86c2220 96 /** @defgroup STM32469I-Discovery_LCD_Private_TypesDefinitions LCD Private TypesDefinitions
bcostm 0:0002c86c2220 97 * @{
bcostm 0:0002c86c2220 98 */
bcostm 0:0002c86c2220 99 static DSI_VidCfgTypeDef hdsivideo_handle;
bcostm 0:0002c86c2220 100
bcostm 0:0002c86c2220 101 /**
bcostm 0:0002c86c2220 102 * @}
bcostm 0:0002c86c2220 103 */
bcostm 0:0002c86c2220 104
bcostm 0:0002c86c2220 105 /** @defgroup STM32469I-Discovery_LCD_Private_Defines LCD Private Defines
bcostm 0:0002c86c2220 106 * @{
bcostm 0:0002c86c2220 107 */
bcostm 0:0002c86c2220 108 /**
bcostm 0:0002c86c2220 109 * @}
bcostm 0:0002c86c2220 110 */
bcostm 0:0002c86c2220 111
bcostm 0:0002c86c2220 112 /** @defgroup STM32469I-Discovery_LCD_Private_Macros LCD Private Macros
bcostm 0:0002c86c2220 113 * @{
bcostm 0:0002c86c2220 114 */
bcostm 0:0002c86c2220 115 #define ABS(X) ((X) > 0 ? (X) : -(X))
bcostm 0:0002c86c2220 116
bcostm 0:0002c86c2220 117 #define POLY_X(Z) ((int32_t)((Points + (Z))->X))
bcostm 0:0002c86c2220 118 #define POLY_Y(Z) ((int32_t)((Points + (Z))->Y))
bcostm 0:0002c86c2220 119 /**
bcostm 0:0002c86c2220 120 * @}
bcostm 0:0002c86c2220 121 */
bcostm 0:0002c86c2220 122
bcostm 0:0002c86c2220 123 /** @defgroup STM32469I-Discovery_LCD_Exported_Variables STM32469I Discovery LCD Exported Variables
bcostm 0:0002c86c2220 124 * @{
bcostm 0:0002c86c2220 125 */
bcostm 0:0002c86c2220 126
bcostm 0:0002c86c2220 127 /**
bcostm 0:0002c86c2220 128 * @}
bcostm 0:0002c86c2220 129 */
bcostm 0:0002c86c2220 130
bcostm 0:0002c86c2220 131
bcostm 0:0002c86c2220 132 /** @defgroup STM32469I-Discovery_LCD_Private_Variables LCD Private Variables
bcostm 0:0002c86c2220 133 * @{
bcostm 0:0002c86c2220 134 */
bcostm 0:0002c86c2220 135
bcostm 0:0002c86c2220 136 DMA2D_HandleTypeDef hdma2d_eval;
bcostm 0:0002c86c2220 137 LTDC_HandleTypeDef hltdc_eval;
bcostm 0:0002c86c2220 138 DSI_HandleTypeDef hdsi_eval;
bcostm 0:0002c86c2220 139 uint32_t lcd_x_size = OTM8009A_800X480_WIDTH;
bcostm 0:0002c86c2220 140 uint32_t lcd_y_size = OTM8009A_800X480_HEIGHT;
bcostm 0:0002c86c2220 141
bcostm 0:0002c86c2220 142 /**
bcostm 0:0002c86c2220 143 * @}
bcostm 0:0002c86c2220 144 */
bcostm 0:0002c86c2220 145
bcostm 0:0002c86c2220 146
bcostm 0:0002c86c2220 147 /** @defgroup STM32469I-Discovery_LCD_Private_Variables LCD Private Variables
bcostm 0:0002c86c2220 148 * @{
bcostm 0:0002c86c2220 149 */
bcostm 0:0002c86c2220 150
bcostm 0:0002c86c2220 151 /**
bcostm 0:0002c86c2220 152 * @brief Default Active LTDC Layer in which drawing is made is LTDC Layer Background
bcostm 0:0002c86c2220 153 */
bcostm 0:0002c86c2220 154 static uint32_t ActiveLayer = LTDC_ACTIVE_LAYER_BACKGROUND;
bcostm 0:0002c86c2220 155
bcostm 0:0002c86c2220 156 /**
bcostm 0:0002c86c2220 157 * @brief Current Drawing Layer properties variable
bcostm 0:0002c86c2220 158 */
bcostm 0:0002c86c2220 159 static LCD_DrawPropTypeDef DrawProp[LTDC_MAX_LAYER_NUMBER];
bcostm 0:0002c86c2220 160 /**
bcostm 0:0002c86c2220 161 * @}
bcostm 0:0002c86c2220 162 */
bcostm 0:0002c86c2220 163
bcostm 0:0002c86c2220 164 /** @defgroup STM32469I-Discovery_LCD_Private_FunctionPrototypes LCD Private FunctionPrototypes
bcostm 0:0002c86c2220 165 * @{
bcostm 0:0002c86c2220 166 */
bcostm 0:0002c86c2220 167 static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
bcostm 0:0002c86c2220 168 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
bcostm 0:0002c86c2220 169 static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex);
bcostm 0:0002c86c2220 170 static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode);
bcostm 0:0002c86c2220 171 /**
bcostm 0:0002c86c2220 172 * @}
bcostm 0:0002c86c2220 173 */
bcostm 0:0002c86c2220 174
bcostm 0:0002c86c2220 175 /** @defgroup STM32469I-Discovery_LCD_Exported_Functions LCD Exported Functions
bcostm 0:0002c86c2220 176 * @{
bcostm 0:0002c86c2220 177 */
bcostm 0:0002c86c2220 178
bcostm 0:0002c86c2220 179 /**
bcostm 0:0002c86c2220 180 * @brief Initializes the DSI LCD.
bcostm 0:0002c86c2220 181 * @param None
bcostm 0:0002c86c2220 182 * @retval LCD state
bcostm 0:0002c86c2220 183 */
bcostm 0:0002c86c2220 184 uint8_t BSP_LCD_Init(void)
bcostm 0:0002c86c2220 185 {
bcostm 0:0002c86c2220 186 return (BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE));
bcostm 0:0002c86c2220 187 }
bcostm 0:0002c86c2220 188
bcostm 0:0002c86c2220 189 /**
bcostm 0:0002c86c2220 190 * @brief Initializes the DSI LCD.
bcostm 0:0002c86c2220 191 * The ititialization is done as below:
bcostm 0:0002c86c2220 192 * - DSI PLL ititialization
bcostm 0:0002c86c2220 193 * - DSI ititialization
bcostm 0:0002c86c2220 194 * - LTDC ititialization
bcostm 0:0002c86c2220 195 * - OTM8009A LCD Display IC Driver ititialization
bcostm 0:0002c86c2220 196 * @param None
bcostm 0:0002c86c2220 197 * @retval LCD state
bcostm 0:0002c86c2220 198 */
bcostm 0:0002c86c2220 199 uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation)
bcostm 0:0002c86c2220 200 {
bcostm 0:0002c86c2220 201 DSI_PLLInitTypeDef dsiPllInit;
bcostm 0:0002c86c2220 202 static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
bcostm 0:0002c86c2220 203 uint32_t LcdClock = 27429; /*!< LcdClk = 27429 kHz */
bcostm 0:0002c86c2220 204 uint32_t Clockratio = 0;
bcostm 0:0002c86c2220 205 uint32_t laneByteClk_kHz = 0;
bcostm 0:0002c86c2220 206 uint32_t VSA; /*!< Vertical start active time in units of lines */
bcostm 0:0002c86c2220 207 uint32_t VBP; /*!< Vertical Back Porch time in units of lines */
bcostm 0:0002c86c2220 208 uint32_t VFP; /*!< Vertical Front Porch time in units of lines */
bcostm 0:0002c86c2220 209 uint32_t VACT; /*!< Vertical Active time in units of lines = imageSize Y in pixels to display */
bcostm 0:0002c86c2220 210 uint32_t HSA; /*!< Horizontal start active time in units of lcdClk */
bcostm 0:0002c86c2220 211 uint32_t HBP; /*!< Horizontal Back Porch time in units of lcdClk */
bcostm 0:0002c86c2220 212 uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */
bcostm 0:0002c86c2220 213 uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */
bcostm 0:0002c86c2220 214
bcostm 0:0002c86c2220 215
bcostm 0:0002c86c2220 216 /* Toggle Hardware Reset of the DSI LCD using
bcostm 0:0002c86c2220 217 * its XRES signal (active low) */
bcostm 0:0002c86c2220 218 BSP_LCD_Reset();
bcostm 0:0002c86c2220 219
bcostm 0:0002c86c2220 220 /* Call first MSP Initialize only in case of first initialization
bcostm 0:0002c86c2220 221 * This will set IP blocks LTDC, DSI and DMA2D
bcostm 0:0002c86c2220 222 * - out of reset
bcostm 0:0002c86c2220 223 * - clocked
bcostm 0:0002c86c2220 224 * - NVIC IRQ related to IP blocks enabled
bcostm 0:0002c86c2220 225 */
bcostm 0:0002c86c2220 226 BSP_LCD_MspInit();
bcostm 0:0002c86c2220 227
bcostm 0:0002c86c2220 228 /*************************DSI Initialization***********************************/
bcostm 0:0002c86c2220 229
bcostm 0:0002c86c2220 230 /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */
bcostm 0:0002c86c2220 231 hdsi_eval.Instance = DSI;
bcostm 0:0002c86c2220 232
bcostm 0:0002c86c2220 233 HAL_DSI_DeInit(&(hdsi_eval));
bcostm 0:0002c86c2220 234
bcostm 0:0002c86c2220 235 #if !defined(USE_STM32469I_DISCO_REVA)
bcostm 0:0002c86c2220 236 dsiPllInit.PLLNDIV = 125;
bcostm 0:0002c86c2220 237 dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2;
bcostm 0:0002c86c2220 238 dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
bcostm 0:0002c86c2220 239 #else
bcostm 0:0002c86c2220 240 dsiPllInit.PLLNDIV = 100;
bcostm 0:0002c86c2220 241 dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5;
bcostm 0:0002c86c2220 242 dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
bcostm 0:0002c86c2220 243 #endif
bcostm 0:0002c86c2220 244 laneByteClk_kHz = 62500; /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */
bcostm 0:0002c86c2220 245
bcostm 0:0002c86c2220 246 /* Set number of Lanes */
bcostm 0:0002c86c2220 247 hdsi_eval.Init.NumberOfLanes = DSI_TWO_DATA_LANES;
bcostm 0:0002c86c2220 248
bcostm 0:0002c86c2220 249 /* TXEscapeCkdiv = f(LaneByteClk)/15.62 = 4 */
bcostm 0:0002c86c2220 250 hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620;
bcostm 0:0002c86c2220 251
bcostm 0:0002c86c2220 252 HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit));
bcostm 0:0002c86c2220 253 Clockratio = laneByteClk_kHz/LcdClock;
bcostm 0:0002c86c2220 254 /* Timing parameters for all Video modes
bcostm 0:0002c86c2220 255 * Set Timing parameters of LTDC depending on its chosen orientation
bcostm 0:0002c86c2220 256 */
bcostm 0:0002c86c2220 257 if(orientation == LCD_ORIENTATION_PORTRAIT)
bcostm 0:0002c86c2220 258 {
bcostm 0:0002c86c2220 259 VSA = OTM8009A_480X800_VSYNC; /* 12 */
bcostm 0:0002c86c2220 260 VBP = OTM8009A_480X800_VBP; /* 12 */
bcostm 0:0002c86c2220 261 VFP = OTM8009A_480X800_VFP; /* 12 */
bcostm 0:0002c86c2220 262 HSA = OTM8009A_480X800_HSYNC; /* 120 */
bcostm 0:0002c86c2220 263 HBP = OTM8009A_480X800_HBP; /* 120 */
bcostm 0:0002c86c2220 264 HFP = OTM8009A_480X800_HFP; /* 120 */
bcostm 0:0002c86c2220 265 lcd_x_size = OTM8009A_480X800_WIDTH; /* 480 */
bcostm 0:0002c86c2220 266 lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */
bcostm 0:0002c86c2220 267 }
bcostm 0:0002c86c2220 268 else
bcostm 0:0002c86c2220 269 {
bcostm 0:0002c86c2220 270 /* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */
bcostm 0:0002c86c2220 271 VSA = OTM8009A_800X480_VSYNC; /* 12 */
bcostm 0:0002c86c2220 272 VBP = OTM8009A_800X480_VBP; /* 12 */
bcostm 0:0002c86c2220 273 VFP = OTM8009A_800X480_VFP; /* 12 */
bcostm 0:0002c86c2220 274 HSA = OTM8009A_800X480_HSYNC; /* 120 */
bcostm 0:0002c86c2220 275 HBP = OTM8009A_800X480_HBP; /* 120 */
bcostm 0:0002c86c2220 276 HFP = OTM8009A_800X480_HFP; /* 120 */
bcostm 0:0002c86c2220 277 lcd_x_size = OTM8009A_800X480_WIDTH; /* 800 */
bcostm 0:0002c86c2220 278 lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */
bcostm 0:0002c86c2220 279 }
bcostm 0:0002c86c2220 280
bcostm 0:0002c86c2220 281 HACT = lcd_x_size;
bcostm 0:0002c86c2220 282 VACT = lcd_y_size;
bcostm 0:0002c86c2220 283
bcostm 0:0002c86c2220 284
bcostm 0:0002c86c2220 285 hdsivideo_handle.VirtualChannelID = LCD_OTM8009A_ID;
bcostm 0:0002c86c2220 286 hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG888;
bcostm 0:0002c86c2220 287 hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH;
bcostm 0:0002c86c2220 288 hdsivideo_handle.HSPolarity = DSI_HSYNC_ACTIVE_HIGH;
bcostm 0:0002c86c2220 289 hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH;
bcostm 0:0002c86c2220 290 hdsivideo_handle.Mode = DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */
bcostm 0:0002c86c2220 291 hdsivideo_handle.NullPacketSize = 0xFFF;
bcostm 0:0002c86c2220 292 hdsivideo_handle.NumberOfChunks = 0;
bcostm 0:0002c86c2220 293 hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */
bcostm 0:0002c86c2220 294 hdsivideo_handle.HorizontalSyncActive = HSA*Clockratio;
bcostm 0:0002c86c2220 295 hdsivideo_handle.HorizontalBackPorch = HBP*Clockratio;
bcostm 0:0002c86c2220 296 hdsivideo_handle.HorizontalLine = (HACT + HSA + HBP + HFP)*Clockratio; /* Value depending on display orientation choice portrait/landscape */
bcostm 0:0002c86c2220 297 hdsivideo_handle.VerticalSyncActive = VSA;
bcostm 0:0002c86c2220 298 hdsivideo_handle.VerticalBackPorch = VBP;
bcostm 0:0002c86c2220 299 hdsivideo_handle.VerticalFrontPorch = VFP;
bcostm 0:0002c86c2220 300 hdsivideo_handle.VerticalActive = VACT; /* Value depending on display orientation choice portrait/landscape */
bcostm 0:0002c86c2220 301
bcostm 0:0002c86c2220 302 /* Enable or disable sending LP command while streaming is active in video mode */
bcostm 0:0002c86c2220 303 hdsivideo_handle.LPCommandEnable = DSI_LP_COMMAND_ENABLE; /* Enable sending commands in mode LP (Low Power) */
bcostm 0:0002c86c2220 304
bcostm 0:0002c86c2220 305 /* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */
bcostm 0:0002c86c2220 306 /* Only useful when sending LP packets is allowed while streaming is active in video mode */
bcostm 0:0002c86c2220 307 hdsivideo_handle.LPLargestPacketSize = 64;
bcostm 0:0002c86c2220 308
bcostm 0:0002c86c2220 309 /* Largest packet size possible to transmit in LP mode in HFP region during VACT period */
bcostm 0:0002c86c2220 310 /* Only useful when sending LP packets is allowed while streaming is active in video mode */
bcostm 0:0002c86c2220 311 hdsivideo_handle.LPVACTLargestPacketSize = 64;
bcostm 0:0002c86c2220 312
bcostm 0:0002c86c2220 313
bcostm 0:0002c86c2220 314 /* Specify for each region of the video frame, if the transmission of command in LP mode is allowed in this region */
bcostm 0:0002c86c2220 315 /* while streaming is active in video mode */
bcostm 0:0002c86c2220 316 hdsivideo_handle.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; /* Allow sending LP commands during HFP period */
bcostm 0:0002c86c2220 317 hdsivideo_handle.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; /* Allow sending LP commands during HBP period */
bcostm 0:0002c86c2220 318 hdsivideo_handle.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; /* Allow sending LP commands during VACT period */
bcostm 0:0002c86c2220 319 hdsivideo_handle.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; /* Allow sending LP commands during VFP period */
bcostm 0:0002c86c2220 320 hdsivideo_handle.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; /* Allow sending LP commands during VBP period */
bcostm 0:0002c86c2220 321 hdsivideo_handle.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; /* Allow sending LP commands during VSync = VSA period */
bcostm 0:0002c86c2220 322
bcostm 0:0002c86c2220 323 /* Configure DSI Video mode timings with settings set above */
bcostm 0:0002c86c2220 324 HAL_DSI_ConfigVideoMode(&(hdsi_eval), &(hdsivideo_handle));
bcostm 0:0002c86c2220 325
bcostm 0:0002c86c2220 326 /* Enable the DSI host and wrapper : but LTDC is not started yet at this stage */
bcostm 0:0002c86c2220 327 HAL_DSI_Start(&(hdsi_eval));
bcostm 0:0002c86c2220 328 /*************************End DSI Initialization*******************************/
bcostm 0:0002c86c2220 329
bcostm 0:0002c86c2220 330
bcostm 0:0002c86c2220 331 /************************LTDC Initialization***********************************/
bcostm 0:0002c86c2220 332
bcostm 0:0002c86c2220 333 /* Timing Configuration */
bcostm 0:0002c86c2220 334 hltdc_eval.Init.HorizontalSync = (HSA - 1);
bcostm 0:0002c86c2220 335 hltdc_eval.Init.AccumulatedHBP = (HSA + HBP - 1);
bcostm 0:0002c86c2220 336 hltdc_eval.Init.AccumulatedActiveW = (lcd_x_size + HSA + HBP - 1);
bcostm 0:0002c86c2220 337 hltdc_eval.Init.TotalWidth = (lcd_x_size + HSA + HBP + HFP - 1);
bcostm 0:0002c86c2220 338
bcostm 0:0002c86c2220 339 /* Initialize the LCD pixel width and pixel height */
bcostm 0:0002c86c2220 340 hltdc_eval.LayerCfg->ImageWidth = lcd_x_size;
bcostm 0:0002c86c2220 341 hltdc_eval.LayerCfg->ImageHeight = lcd_y_size;
bcostm 0:0002c86c2220 342
bcostm 0:0002c86c2220 343
bcostm 0:0002c86c2220 344 /* LCD clock configuration */
bcostm 0:0002c86c2220 345 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
bcostm 0:0002c86c2220 346 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */
bcostm 0:0002c86c2220 347 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */
bcostm 0:0002c86c2220 348 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */
bcostm 0:0002c86c2220 349 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
bcostm 0:0002c86c2220 350 PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
bcostm 0:0002c86c2220 351 PeriphClkInitStruct.PLLSAI.PLLSAIR = 7;
bcostm 0:0002c86c2220 352 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
bcostm 0:0002c86c2220 353 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
bcostm 0:0002c86c2220 354
bcostm 0:0002c86c2220 355 /* Background value */
bcostm 0:0002c86c2220 356 hltdc_eval.Init.Backcolor.Blue = 0;
bcostm 0:0002c86c2220 357 hltdc_eval.Init.Backcolor.Green = 0;
bcostm 0:0002c86c2220 358 hltdc_eval.Init.Backcolor.Red = 0;
bcostm 0:0002c86c2220 359 hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
bcostm 0:0002c86c2220 360 hltdc_eval.Instance = LTDC;
bcostm 0:0002c86c2220 361
bcostm 0:0002c86c2220 362 /* Get LTDC Configuration from DSI Configuration */
bcostm 0:0002c86c2220 363 HAL_LTDC_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle));
bcostm 0:0002c86c2220 364
bcostm 0:0002c86c2220 365 /* Initialize the LTDC */
bcostm 0:0002c86c2220 366 HAL_LTDC_Init(&hltdc_eval);
bcostm 0:0002c86c2220 367
bcostm 0:0002c86c2220 368 #if !defined(DATA_IN_ExtSDRAM)
bcostm 0:0002c86c2220 369 /* Initialize the SDRAM */
bcostm 0:0002c86c2220 370 BSP_SDRAM_Init();
bcostm 0:0002c86c2220 371 #endif /* DATA_IN_ExtSDRAM */
bcostm 0:0002c86c2220 372
bcostm 0:0002c86c2220 373 /* Initialize the font */
bcostm 0:0002c86c2220 374 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
bcostm 0:0002c86c2220 375
bcostm 0:0002c86c2220 376 /************************End LTDC Initialization*******************************/
bcostm 0:0002c86c2220 377
bcostm 0:0002c86c2220 378
bcostm 0:0002c86c2220 379 /***********************OTM8009A Initialization********************************/
bcostm 0:0002c86c2220 380
bcostm 0:0002c86c2220 381 /* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver)
bcostm 0:0002c86c2220 382 * depending on configuration set in 'hdsivideo_handle'.
bcostm 0:0002c86c2220 383 */
bcostm 0:0002c86c2220 384 OTM8009A_Init(hdsivideo_handle.ColorCoding, orientation);
bcostm 0:0002c86c2220 385
bcostm 0:0002c86c2220 386 /***********************End OTM8009A Initialization****************************/
bcostm 0:0002c86c2220 387
bcostm 0:0002c86c2220 388 return LCD_OK;
bcostm 0:0002c86c2220 389 }
bcostm 0:0002c86c2220 390
bcostm 0:0002c86c2220 391 /**
bcostm 0:0002c86c2220 392 * @brief BSP LCD Reset
bcostm 0:0002c86c2220 393 * Hw reset the LCD DSI activating its XRES signal (active low for some time)
bcostm 0:0002c86c2220 394 * and desactivating it later.
bcostm 0:0002c86c2220 395 * This signal is only cabled on Discovery Rev B and beyond.
bcostm 0:0002c86c2220 396 */
bcostm 0:0002c86c2220 397 void BSP_LCD_Reset(void)
bcostm 0:0002c86c2220 398 {
bcostm 0:0002c86c2220 399 #if !defined(USE_STM32469I_DISCO_REVA)
bcostm 0:0002c86c2220 400 /* EVAL Rev B and beyond : reset the LCD by activation of XRES (active low) connected to PH7 */
bcostm 0:0002c86c2220 401 GPIO_InitTypeDef gpio_init_structure;
bcostm 0:0002c86c2220 402
bcostm 0:0002c86c2220 403 __HAL_RCC_GPIOH_CLK_ENABLE();
bcostm 0:0002c86c2220 404
bcostm 0:0002c86c2220 405 /* Configure the GPIO on PH7 */
bcostm 0:0002c86c2220 406 gpio_init_structure.Pin = GPIO_PIN_7;
bcostm 0:0002c86c2220 407 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_OD;
bcostm 0:0002c86c2220 408 gpio_init_structure.Pull = GPIO_NOPULL;
bcostm 0:0002c86c2220 409 gpio_init_structure.Speed = GPIO_SPEED_HIGH;
bcostm 0:0002c86c2220 410
bcostm 0:0002c86c2220 411 HAL_GPIO_Init(GPIOH, &gpio_init_structure);
bcostm 0:0002c86c2220 412
bcostm 0:0002c86c2220 413 /* Activate XRES active low */
bcostm 0:0002c86c2220 414 HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET);
bcostm 0:0002c86c2220 415
bcostm 0:0002c86c2220 416 //HAL_Delay(20); /* wait 20 ms */
bcostm 0:0002c86c2220 417 wait_ms(20);
bcostm 0:0002c86c2220 418
bcostm 0:0002c86c2220 419 /* Desactivate XRES */
bcostm 0:0002c86c2220 420 HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET);
bcostm 0:0002c86c2220 421
bcostm 0:0002c86c2220 422 /* Wait for 10ms after releasing XRES before sending commands */
bcostm 0:0002c86c2220 423 //HAL_Delay(10);
bcostm 0:0002c86c2220 424 wait_ms(10);
bcostm 0:0002c86c2220 425 #else
bcostm 0:0002c86c2220 426
bcostm 0:0002c86c2220 427 #endif /* USE_STM32469I_DISCO_REVA == 0 */
bcostm 0:0002c86c2220 428 }
bcostm 0:0002c86c2220 429
bcostm 0:0002c86c2220 430 /**
bcostm 0:0002c86c2220 431 * @brief Gets the LCD X size.
bcostm 0:0002c86c2220 432 * @retval Used LCD X size
bcostm 0:0002c86c2220 433 */
bcostm 0:0002c86c2220 434 uint32_t BSP_LCD_GetXSize(void)
bcostm 0:0002c86c2220 435 {
bcostm 0:0002c86c2220 436 return (lcd_x_size);
bcostm 0:0002c86c2220 437 }
bcostm 0:0002c86c2220 438
bcostm 0:0002c86c2220 439 /**
bcostm 0:0002c86c2220 440 * @brief Gets the LCD Y size.
bcostm 0:0002c86c2220 441 * @retval Used LCD Y size
bcostm 0:0002c86c2220 442 */
bcostm 0:0002c86c2220 443 uint32_t BSP_LCD_GetYSize(void)
bcostm 0:0002c86c2220 444 {
bcostm 0:0002c86c2220 445 return (lcd_y_size);
bcostm 0:0002c86c2220 446 }
bcostm 0:0002c86c2220 447
bcostm 0:0002c86c2220 448 /**
bcostm 0:0002c86c2220 449 * @brief Set the LCD X size.
bcostm 0:0002c86c2220 450 * @param imageWidthPixels : uint32_t image width in pixels unit
bcostm 0:0002c86c2220 451 * @retval None
bcostm 0:0002c86c2220 452 */
bcostm 0:0002c86c2220 453 void BSP_LCD_SetXSize(uint32_t imageWidthPixels)
bcostm 0:0002c86c2220 454 {
bcostm 0:0002c86c2220 455 hltdc_eval.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels;
bcostm 0:0002c86c2220 456 }
bcostm 0:0002c86c2220 457
bcostm 0:0002c86c2220 458 /**
bcostm 0:0002c86c2220 459 * @brief Set the LCD Y size.
bcostm 0:0002c86c2220 460 * @param imageHeightPixels : uint32_t image height in lines unit
bcostm 0:0002c86c2220 461 */
bcostm 0:0002c86c2220 462 void BSP_LCD_SetYSize(uint32_t imageHeightPixels)
bcostm 0:0002c86c2220 463 {
bcostm 0:0002c86c2220 464 hltdc_eval.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels;
bcostm 0:0002c86c2220 465 }
bcostm 0:0002c86c2220 466
bcostm 0:0002c86c2220 467
bcostm 0:0002c86c2220 468 /**
bcostm 0:0002c86c2220 469 * @brief Initializes the LCD layers.
bcostm 0:0002c86c2220 470 * @param LayerIndex: Layer foreground or background
bcostm 0:0002c86c2220 471 * @param FB_Address: Layer frame buffer
bcostm 0:0002c86c2220 472 * @retval None
bcostm 0:0002c86c2220 473 */
bcostm 0:0002c86c2220 474 void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address)
bcostm 0:0002c86c2220 475 {
bcostm 0:0002c86c2220 476 LCD_LayerCfgTypeDef Layercfg;
bcostm 0:0002c86c2220 477
bcostm 0:0002c86c2220 478 /* Layer Init */
bcostm 0:0002c86c2220 479 Layercfg.WindowX0 = 0;
bcostm 0:0002c86c2220 480 Layercfg.WindowX1 = BSP_LCD_GetXSize();
bcostm 0:0002c86c2220 481 Layercfg.WindowY0 = 0;
bcostm 0:0002c86c2220 482 Layercfg.WindowY1 = BSP_LCD_GetYSize();
bcostm 0:0002c86c2220 483 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
bcostm 0:0002c86c2220 484 Layercfg.FBStartAdress = FB_Address;
bcostm 0:0002c86c2220 485 Layercfg.Alpha = 255;
bcostm 0:0002c86c2220 486 Layercfg.Alpha0 = 0;
bcostm 0:0002c86c2220 487 Layercfg.Backcolor.Blue = 0;
bcostm 0:0002c86c2220 488 Layercfg.Backcolor.Green = 0;
bcostm 0:0002c86c2220 489 Layercfg.Backcolor.Red = 0;
bcostm 0:0002c86c2220 490 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
bcostm 0:0002c86c2220 491 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
bcostm 0:0002c86c2220 492 Layercfg.ImageWidth = BSP_LCD_GetXSize();
bcostm 0:0002c86c2220 493 Layercfg.ImageHeight = BSP_LCD_GetYSize();
bcostm 0:0002c86c2220 494
bcostm 0:0002c86c2220 495 HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex);
bcostm 0:0002c86c2220 496
bcostm 0:0002c86c2220 497 DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE;
bcostm 0:0002c86c2220 498 DrawProp[LayerIndex].pFont = &Font24;
bcostm 0:0002c86c2220 499 DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK;
bcostm 0:0002c86c2220 500 }
bcostm 0:0002c86c2220 501
bcostm 0:0002c86c2220 502
bcostm 0:0002c86c2220 503 /**
bcostm 0:0002c86c2220 504 * @brief Selects the LCD Layer.
bcostm 0:0002c86c2220 505 * @param LayerIndex: Layer foreground or background
bcostm 0:0002c86c2220 506 */
bcostm 0:0002c86c2220 507 void BSP_LCD_SelectLayer(uint32_t LayerIndex)
bcostm 0:0002c86c2220 508 {
bcostm 0:0002c86c2220 509 ActiveLayer = LayerIndex;
bcostm 0:0002c86c2220 510 }
bcostm 0:0002c86c2220 511
bcostm 0:0002c86c2220 512 /**
bcostm 0:0002c86c2220 513 * @brief Sets an LCD Layer visible
bcostm 0:0002c86c2220 514 * @param LayerIndex: Visible Layer
bcostm 0:0002c86c2220 515 * @param State: New state of the specified layer
bcostm 0:0002c86c2220 516 * This parameter can be one of the following values:
bcostm 0:0002c86c2220 517 * @arg ENABLE
bcostm 0:0002c86c2220 518 * @arg DISABLE
bcostm 0:0002c86c2220 519 */
bcostm 0:0002c86c2220 520 void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State)
bcostm 0:0002c86c2220 521 {
bcostm 0:0002c86c2220 522 if(State == ENABLE)
bcostm 0:0002c86c2220 523 {
bcostm 0:0002c86c2220 524 __HAL_LTDC_LAYER_ENABLE(&(hltdc_eval), LayerIndex);
bcostm 0:0002c86c2220 525 }
bcostm 0:0002c86c2220 526 else
bcostm 0:0002c86c2220 527 {
bcostm 0:0002c86c2220 528 __HAL_LTDC_LAYER_DISABLE(&(hltdc_eval), LayerIndex);
bcostm 0:0002c86c2220 529 }
bcostm 0:0002c86c2220 530 __HAL_LTDC_RELOAD_CONFIG(&(hltdc_eval));
bcostm 0:0002c86c2220 531
bcostm 0:0002c86c2220 532 }
bcostm 0:0002c86c2220 533
bcostm 0:0002c86c2220 534 /**
bcostm 0:0002c86c2220 535 * @brief Configures the transparency.
bcostm 0:0002c86c2220 536 * @param LayerIndex: Layer foreground or background.
bcostm 0:0002c86c2220 537 * @param Transparency: Transparency
bcostm 0:0002c86c2220 538 * This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF
bcostm 0:0002c86c2220 539 */
bcostm 0:0002c86c2220 540 void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency)
bcostm 0:0002c86c2220 541 {
bcostm 0:0002c86c2220 542
bcostm 0:0002c86c2220 543 HAL_LTDC_SetAlpha(&(hltdc_eval), Transparency, LayerIndex);
bcostm 0:0002c86c2220 544
bcostm 0:0002c86c2220 545 }
bcostm 0:0002c86c2220 546
bcostm 0:0002c86c2220 547 /**
bcostm 0:0002c86c2220 548 * @brief Sets an LCD layer frame buffer address.
bcostm 0:0002c86c2220 549 * @param LayerIndex: Layer foreground or background
bcostm 0:0002c86c2220 550 * @param Address: New LCD frame buffer value
bcostm 0:0002c86c2220 551 */
bcostm 0:0002c86c2220 552 void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address)
bcostm 0:0002c86c2220 553 {
bcostm 0:0002c86c2220 554
bcostm 0:0002c86c2220 555 HAL_LTDC_SetAddress(&(hltdc_eval), Address, LayerIndex);
bcostm 0:0002c86c2220 556
bcostm 0:0002c86c2220 557 }
bcostm 0:0002c86c2220 558
bcostm 0:0002c86c2220 559 /**
bcostm 0:0002c86c2220 560 * @brief Sets display window.
bcostm 0:0002c86c2220 561 * @param LayerIndex: Layer index
bcostm 0:0002c86c2220 562 * @param Xpos: LCD X position
bcostm 0:0002c86c2220 563 * @param Ypos: LCD Y position
bcostm 0:0002c86c2220 564 * @param Width: LCD window width
bcostm 0:0002c86c2220 565 * @param Height: LCD window height
bcostm 0:0002c86c2220 566 */
bcostm 0:0002c86c2220 567 void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:0002c86c2220 568 {
bcostm 0:0002c86c2220 569 /* Reconfigure the layer size */
bcostm 0:0002c86c2220 570 HAL_LTDC_SetWindowSize(&(hltdc_eval), Width, Height, LayerIndex);
bcostm 0:0002c86c2220 571
bcostm 0:0002c86c2220 572 /* Reconfigure the layer position */
bcostm 0:0002c86c2220 573 HAL_LTDC_SetWindowPosition(&(hltdc_eval), Xpos, Ypos, LayerIndex);
bcostm 0:0002c86c2220 574
bcostm 0:0002c86c2220 575 }
bcostm 0:0002c86c2220 576
bcostm 0:0002c86c2220 577 /**
bcostm 0:0002c86c2220 578 * @brief Configures and sets the color keying.
bcostm 0:0002c86c2220 579 * @param LayerIndex: Layer foreground or background
bcostm 0:0002c86c2220 580 * @param RGBValue: Color reference
bcostm 0:0002c86c2220 581 */
bcostm 0:0002c86c2220 582 void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue)
bcostm 0:0002c86c2220 583 {
bcostm 0:0002c86c2220 584 /* Configure and Enable the color Keying for LCD Layer */
bcostm 0:0002c86c2220 585 HAL_LTDC_ConfigColorKeying(&(hltdc_eval), RGBValue, LayerIndex);
bcostm 0:0002c86c2220 586 HAL_LTDC_EnableColorKeying(&(hltdc_eval), LayerIndex);
bcostm 0:0002c86c2220 587 }
bcostm 0:0002c86c2220 588
bcostm 0:0002c86c2220 589 /**
bcostm 0:0002c86c2220 590 * @brief Disables the color keying.
bcostm 0:0002c86c2220 591 * @param LayerIndex: Layer foreground or background
bcostm 0:0002c86c2220 592 */
bcostm 0:0002c86c2220 593 void BSP_LCD_ResetColorKeying(uint32_t LayerIndex)
bcostm 0:0002c86c2220 594 {
bcostm 0:0002c86c2220 595 /* Disable the color Keying for LCD Layer */
bcostm 0:0002c86c2220 596 HAL_LTDC_DisableColorKeying(&(hltdc_eval), LayerIndex);
bcostm 0:0002c86c2220 597 }
bcostm 0:0002c86c2220 598
bcostm 0:0002c86c2220 599 /**
bcostm 0:0002c86c2220 600 * @brief Sets the LCD text color.
bcostm 0:0002c86c2220 601 * @param Color: Text color code ARGB(8-8-8-8)
bcostm 0:0002c86c2220 602 */
bcostm 0:0002c86c2220 603 void BSP_LCD_SetTextColor(uint32_t Color)
bcostm 0:0002c86c2220 604 {
bcostm 0:0002c86c2220 605 DrawProp[ActiveLayer].TextColor = Color;
bcostm 0:0002c86c2220 606 }
bcostm 0:0002c86c2220 607
bcostm 0:0002c86c2220 608 /**
bcostm 0:0002c86c2220 609 * @brief Gets the LCD text color.
bcostm 0:0002c86c2220 610 * @retval Used text color.
bcostm 0:0002c86c2220 611 */
bcostm 0:0002c86c2220 612 uint32_t BSP_LCD_GetTextColor(void)
bcostm 0:0002c86c2220 613 {
bcostm 0:0002c86c2220 614 return DrawProp[ActiveLayer].TextColor;
bcostm 0:0002c86c2220 615 }
bcostm 0:0002c86c2220 616
bcostm 0:0002c86c2220 617 /**
bcostm 0:0002c86c2220 618 * @brief Sets the LCD background color.
bcostm 0:0002c86c2220 619 * @param Color: Layer background color code ARGB(8-8-8-8)
bcostm 0:0002c86c2220 620 */
bcostm 0:0002c86c2220 621 void BSP_LCD_SetBackColor(uint32_t Color)
bcostm 0:0002c86c2220 622 {
bcostm 0:0002c86c2220 623 DrawProp[ActiveLayer].BackColor = Color;
bcostm 0:0002c86c2220 624 }
bcostm 0:0002c86c2220 625
bcostm 0:0002c86c2220 626 /**
bcostm 0:0002c86c2220 627 * @brief Gets the LCD background color.
bcostm 0:0002c86c2220 628 * @retval Used background color
bcostm 0:0002c86c2220 629 */
bcostm 0:0002c86c2220 630 uint32_t BSP_LCD_GetBackColor(void)
bcostm 0:0002c86c2220 631 {
bcostm 0:0002c86c2220 632 return DrawProp[ActiveLayer].BackColor;
bcostm 0:0002c86c2220 633 }
bcostm 0:0002c86c2220 634
bcostm 0:0002c86c2220 635 /**
bcostm 0:0002c86c2220 636 * @brief Sets the LCD text font.
bcostm 0:0002c86c2220 637 * @param fonts: Layer font to be used
bcostm 0:0002c86c2220 638 */
bcostm 0:0002c86c2220 639 void BSP_LCD_SetFont(sFONT *fonts)
bcostm 0:0002c86c2220 640 {
bcostm 0:0002c86c2220 641 DrawProp[ActiveLayer].pFont = fonts;
bcostm 0:0002c86c2220 642 }
bcostm 0:0002c86c2220 643
bcostm 0:0002c86c2220 644 /**
bcostm 0:0002c86c2220 645 * @brief Gets the LCD text font.
bcostm 0:0002c86c2220 646 * @retval Used layer font
bcostm 0:0002c86c2220 647 */
bcostm 0:0002c86c2220 648 sFONT *BSP_LCD_GetFont(void)
bcostm 0:0002c86c2220 649 {
bcostm 0:0002c86c2220 650 return DrawProp[ActiveLayer].pFont;
bcostm 0:0002c86c2220 651 }
bcostm 0:0002c86c2220 652
bcostm 0:0002c86c2220 653 /**
bcostm 0:0002c86c2220 654 * @brief Reads an LCD pixel.
bcostm 0:0002c86c2220 655 * @param Xpos: X position
bcostm 0:0002c86c2220 656 * @param Ypos: Y position
bcostm 0:0002c86c2220 657 * @retval RGB pixel color
bcostm 0:0002c86c2220 658 */
bcostm 0:0002c86c2220 659 uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
bcostm 0:0002c86c2220 660 {
bcostm 0:0002c86c2220 661 uint32_t ret = 0;
bcostm 0:0002c86c2220 662
bcostm 0:0002c86c2220 663 if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
bcostm 0:0002c86c2220 664 {
bcostm 0:0002c86c2220 665 /* Read data value from SDRAM memory */
bcostm 0:0002c86c2220 666 ret = *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));
bcostm 0:0002c86c2220 667 }
bcostm 0:0002c86c2220 668 else if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
bcostm 0:0002c86c2220 669 {
bcostm 0:0002c86c2220 670 /* Read data value from SDRAM memory */
bcostm 0:0002c86c2220 671 ret = (*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF);
bcostm 0:0002c86c2220 672 }
bcostm 0:0002c86c2220 673 else if((hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
bcostm 0:0002c86c2220 674 (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
bcostm 0:0002c86c2220 675 (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88))
bcostm 0:0002c86c2220 676 {
bcostm 0:0002c86c2220 677 /* Read data value from SDRAM memory */
bcostm 0:0002c86c2220 678 ret = *(__IO uint16_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));
bcostm 0:0002c86c2220 679 }
bcostm 0:0002c86c2220 680 else
bcostm 0:0002c86c2220 681 {
bcostm 0:0002c86c2220 682 /* Read data value from SDRAM memory */
bcostm 0:0002c86c2220 683 ret = *(__IO uint8_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));
bcostm 0:0002c86c2220 684 }
bcostm 0:0002c86c2220 685
bcostm 0:0002c86c2220 686 return ret;
bcostm 0:0002c86c2220 687 }
bcostm 0:0002c86c2220 688
bcostm 0:0002c86c2220 689 /**
bcostm 0:0002c86c2220 690 * @brief Clears the whole currently active layer of LTDC.
bcostm 0:0002c86c2220 691 * @param Color: Color of the background
bcostm 0:0002c86c2220 692 */
bcostm 0:0002c86c2220 693 void BSP_LCD_Clear(uint32_t Color)
bcostm 0:0002c86c2220 694 {
bcostm 0:0002c86c2220 695 /* Clear the LCD */
bcostm 0:0002c86c2220 696 LL_FillBuffer(ActiveLayer, (uint32_t *)(hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color);
bcostm 0:0002c86c2220 697 }
bcostm 0:0002c86c2220 698
bcostm 0:0002c86c2220 699 /**
bcostm 0:0002c86c2220 700 * @brief Clears the selected line in currently active layer.
bcostm 0:0002c86c2220 701 * @param Line: Line to be cleared
bcostm 0:0002c86c2220 702 */
bcostm 0:0002c86c2220 703 void BSP_LCD_ClearStringLine(uint32_t Line)
bcostm 0:0002c86c2220 704 {
bcostm 0:0002c86c2220 705 uint32_t color_backup = DrawProp[ActiveLayer].TextColor;
bcostm 0:0002c86c2220 706 DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor;
bcostm 0:0002c86c2220 707
bcostm 0:0002c86c2220 708 /* Draw rectangle with background color */
bcostm 0:0002c86c2220 709 BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height);
bcostm 0:0002c86c2220 710
bcostm 0:0002c86c2220 711 DrawProp[ActiveLayer].TextColor = color_backup;
bcostm 0:0002c86c2220 712 BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 713 }
bcostm 0:0002c86c2220 714
bcostm 0:0002c86c2220 715 /**
bcostm 0:0002c86c2220 716 * @brief Displays one character in currently active layer.
bcostm 0:0002c86c2220 717 * @param Xpos: Start column address
bcostm 0:0002c86c2220 718 * @param Ypos: Line where to display the character shape.
bcostm 0:0002c86c2220 719 * @param Ascii: Character ascii code
bcostm 0:0002c86c2220 720 * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E
bcostm 0:0002c86c2220 721 */
bcostm 0:0002c86c2220 722 void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
bcostm 0:0002c86c2220 723 {
bcostm 0:0002c86c2220 724 DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\
bcostm 0:0002c86c2220 725 DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]);
bcostm 0:0002c86c2220 726 }
bcostm 0:0002c86c2220 727
bcostm 0:0002c86c2220 728 /**
bcostm 0:0002c86c2220 729 * @brief Displays characters in currently active layer.
bcostm 0:0002c86c2220 730 * @param Xpos: X position (in pixel)
bcostm 0:0002c86c2220 731 * @param Ypos: Y position (in pixel)
bcostm 0:0002c86c2220 732 * @param Text: Pointer to string to display on LCD
bcostm 0:0002c86c2220 733 * @param Mode: Display mode
bcostm 0:0002c86c2220 734 * This parameter can be one of the following values:
bcostm 0:0002c86c2220 735 * @arg CENTER_MODE
bcostm 0:0002c86c2220 736 * @arg RIGHT_MODE
bcostm 0:0002c86c2220 737 * @arg LEFT_MODE
bcostm 0:0002c86c2220 738 */
bcostm 0:0002c86c2220 739 void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
bcostm 0:0002c86c2220 740 {
bcostm 0:0002c86c2220 741 uint16_t refcolumn = 1, i = 0;
bcostm 0:0002c86c2220 742 uint32_t size = 0, xsize = 0;
bcostm 0:0002c86c2220 743 uint8_t *ptr = Text;
bcostm 0:0002c86c2220 744
bcostm 0:0002c86c2220 745 /* Get the text size */
bcostm 0:0002c86c2220 746 while (*ptr++) size ++ ;
bcostm 0:0002c86c2220 747
bcostm 0:0002c86c2220 748 /* Characters number per line */
bcostm 0:0002c86c2220 749 xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width);
bcostm 0:0002c86c2220 750
bcostm 0:0002c86c2220 751 switch (Mode)
bcostm 0:0002c86c2220 752 {
bcostm 0:0002c86c2220 753 case CENTER_MODE:
bcostm 0:0002c86c2220 754 {
bcostm 0:0002c86c2220 755 refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2;
bcostm 0:0002c86c2220 756 break;
bcostm 0:0002c86c2220 757 }
bcostm 0:0002c86c2220 758 case LEFT_MODE:
bcostm 0:0002c86c2220 759 {
bcostm 0:0002c86c2220 760 refcolumn = Xpos;
bcostm 0:0002c86c2220 761 break;
bcostm 0:0002c86c2220 762 }
bcostm 0:0002c86c2220 763 case RIGHT_MODE:
bcostm 0:0002c86c2220 764 {
bcostm 0:0002c86c2220 765 refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width);
bcostm 0:0002c86c2220 766 break;
bcostm 0:0002c86c2220 767 }
bcostm 0:0002c86c2220 768 default:
bcostm 0:0002c86c2220 769 {
bcostm 0:0002c86c2220 770 refcolumn = Xpos;
bcostm 0:0002c86c2220 771 break;
bcostm 0:0002c86c2220 772 }
bcostm 0:0002c86c2220 773 }
bcostm 0:0002c86c2220 774
bcostm 0:0002c86c2220 775 /* Check that the Start column is located in the screen */
bcostm 0:0002c86c2220 776 if ((refcolumn < 1) || (refcolumn >= 0x8000))
bcostm 0:0002c86c2220 777 {
bcostm 0:0002c86c2220 778 refcolumn = 1;
bcostm 0:0002c86c2220 779 }
bcostm 0:0002c86c2220 780
bcostm 0:0002c86c2220 781 /* Send the string character by character on LCD */
bcostm 0:0002c86c2220 782 while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width))
bcostm 0:0002c86c2220 783 {
bcostm 0:0002c86c2220 784 /* Display one character on LCD */
bcostm 0:0002c86c2220 785 BSP_LCD_DisplayChar(refcolumn, Ypos, *Text);
bcostm 0:0002c86c2220 786 /* Decrement the column position by 16 */
bcostm 0:0002c86c2220 787 refcolumn += DrawProp[ActiveLayer].pFont->Width;
bcostm 0:0002c86c2220 788
bcostm 0:0002c86c2220 789 /* Point on the next character */
bcostm 0:0002c86c2220 790 Text++;
bcostm 0:0002c86c2220 791 i++;
bcostm 0:0002c86c2220 792 }
bcostm 0:0002c86c2220 793
bcostm 0:0002c86c2220 794 }
bcostm 0:0002c86c2220 795
bcostm 0:0002c86c2220 796 /**
bcostm 0:0002c86c2220 797 * @brief Displays a maximum of 60 characters on the LCD.
bcostm 0:0002c86c2220 798 * @param Line: Line where to display the character shape
bcostm 0:0002c86c2220 799 * @param ptr: Pointer to string to display on LCD
bcostm 0:0002c86c2220 800 */
bcostm 0:0002c86c2220 801 void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
bcostm 0:0002c86c2220 802 {
bcostm 0:0002c86c2220 803 BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE);
bcostm 0:0002c86c2220 804 }
bcostm 0:0002c86c2220 805
bcostm 0:0002c86c2220 806 /**
bcostm 0:0002c86c2220 807 * @brief Draws an horizontal line in currently active layer.
bcostm 0:0002c86c2220 808 * @param Xpos: X position
bcostm 0:0002c86c2220 809 * @param Ypos: Y position
bcostm 0:0002c86c2220 810 * @param Length: Line length
bcostm 0:0002c86c2220 811 */
bcostm 0:0002c86c2220 812 void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
bcostm 0:0002c86c2220 813 {
bcostm 0:0002c86c2220 814 uint32_t Xaddress = 0;
bcostm 0:0002c86c2220 815
bcostm 0:0002c86c2220 816 /* Get the line address */
bcostm 0:0002c86c2220 817 Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
bcostm 0:0002c86c2220 818
bcostm 0:0002c86c2220 819 /* Write line */
bcostm 0:0002c86c2220 820 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 821 }
bcostm 0:0002c86c2220 822
bcostm 0:0002c86c2220 823 /**
bcostm 0:0002c86c2220 824 * @brief Draws a vertical line in currently active layer.
bcostm 0:0002c86c2220 825 * @param Xpos: X position
bcostm 0:0002c86c2220 826 * @param Ypos: Y position
bcostm 0:0002c86c2220 827 * @param Length: Line length
bcostm 0:0002c86c2220 828 */
bcostm 0:0002c86c2220 829 void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
bcostm 0:0002c86c2220 830 {
bcostm 0:0002c86c2220 831 uint32_t Xaddress = 0;
bcostm 0:0002c86c2220 832
bcostm 0:0002c86c2220 833 /* Get the line address */
bcostm 0:0002c86c2220 834 Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
bcostm 0:0002c86c2220 835
bcostm 0:0002c86c2220 836 /* Write line */
bcostm 0:0002c86c2220 837 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 838 }
bcostm 0:0002c86c2220 839
bcostm 0:0002c86c2220 840 /**
bcostm 0:0002c86c2220 841 * @brief Draws an uni-line (between two points) in currently active layer.
bcostm 0:0002c86c2220 842 * @param x1: Point 1 X position
bcostm 0:0002c86c2220 843 * @param y1: Point 1 Y position
bcostm 0:0002c86c2220 844 * @param x2: Point 2 X position
bcostm 0:0002c86c2220 845 * @param y2: Point 2 Y position
bcostm 0:0002c86c2220 846 */
bcostm 0:0002c86c2220 847 void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
bcostm 0:0002c86c2220 848 {
bcostm 0:0002c86c2220 849 int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
bcostm 0:0002c86c2220 850 yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
bcostm 0:0002c86c2220 851 curpixel = 0;
bcostm 0:0002c86c2220 852
bcostm 0:0002c86c2220 853 deltax = ABS(x2 - x1); /* The difference between the x's */
bcostm 0:0002c86c2220 854 deltay = ABS(y2 - y1); /* The difference between the y's */
bcostm 0:0002c86c2220 855 x = x1; /* Start x off at the first pixel */
bcostm 0:0002c86c2220 856 y = y1; /* Start y off at the first pixel */
bcostm 0:0002c86c2220 857
bcostm 0:0002c86c2220 858 if (x2 >= x1) /* The x-values are increasing */
bcostm 0:0002c86c2220 859 {
bcostm 0:0002c86c2220 860 xinc1 = 1;
bcostm 0:0002c86c2220 861 xinc2 = 1;
bcostm 0:0002c86c2220 862 }
bcostm 0:0002c86c2220 863 else /* The x-values are decreasing */
bcostm 0:0002c86c2220 864 {
bcostm 0:0002c86c2220 865 xinc1 = -1;
bcostm 0:0002c86c2220 866 xinc2 = -1;
bcostm 0:0002c86c2220 867 }
bcostm 0:0002c86c2220 868
bcostm 0:0002c86c2220 869 if (y2 >= y1) /* The y-values are increasing */
bcostm 0:0002c86c2220 870 {
bcostm 0:0002c86c2220 871 yinc1 = 1;
bcostm 0:0002c86c2220 872 yinc2 = 1;
bcostm 0:0002c86c2220 873 }
bcostm 0:0002c86c2220 874 else /* The y-values are decreasing */
bcostm 0:0002c86c2220 875 {
bcostm 0:0002c86c2220 876 yinc1 = -1;
bcostm 0:0002c86c2220 877 yinc2 = -1;
bcostm 0:0002c86c2220 878 }
bcostm 0:0002c86c2220 879
bcostm 0:0002c86c2220 880 if (deltax >= deltay) /* There is at least one x-value for every y-value */
bcostm 0:0002c86c2220 881 {
bcostm 0:0002c86c2220 882 xinc1 = 0; /* Don't change the x when numerator >= denominator */
bcostm 0:0002c86c2220 883 yinc2 = 0; /* Don't change the y for every iteration */
bcostm 0:0002c86c2220 884 den = deltax;
bcostm 0:0002c86c2220 885 num = deltax / 2;
bcostm 0:0002c86c2220 886 numadd = deltay;
bcostm 0:0002c86c2220 887 numpixels = deltax; /* There are more x-values than y-values */
bcostm 0:0002c86c2220 888 }
bcostm 0:0002c86c2220 889 else /* There is at least one y-value for every x-value */
bcostm 0:0002c86c2220 890 {
bcostm 0:0002c86c2220 891 xinc2 = 0; /* Don't change the x for every iteration */
bcostm 0:0002c86c2220 892 yinc1 = 0; /* Don't change the y when numerator >= denominator */
bcostm 0:0002c86c2220 893 den = deltay;
bcostm 0:0002c86c2220 894 num = deltay / 2;
bcostm 0:0002c86c2220 895 numadd = deltax;
bcostm 0:0002c86c2220 896 numpixels = deltay; /* There are more y-values than x-values */
bcostm 0:0002c86c2220 897 }
bcostm 0:0002c86c2220 898
bcostm 0:0002c86c2220 899 for (curpixel = 0; curpixel <= numpixels; curpixel++)
bcostm 0:0002c86c2220 900 {
bcostm 0:0002c86c2220 901 BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */
bcostm 0:0002c86c2220 902 num += numadd; /* Increase the numerator by the top of the fraction */
bcostm 0:0002c86c2220 903 if (num >= den) /* Check if numerator >= denominator */
bcostm 0:0002c86c2220 904 {
bcostm 0:0002c86c2220 905 num -= den; /* Calculate the new numerator value */
bcostm 0:0002c86c2220 906 x += xinc1; /* Change the x as appropriate */
bcostm 0:0002c86c2220 907 y += yinc1; /* Change the y as appropriate */
bcostm 0:0002c86c2220 908 }
bcostm 0:0002c86c2220 909 x += xinc2; /* Change the x as appropriate */
bcostm 0:0002c86c2220 910 y += yinc2; /* Change the y as appropriate */
bcostm 0:0002c86c2220 911 }
bcostm 0:0002c86c2220 912 }
bcostm 0:0002c86c2220 913
bcostm 0:0002c86c2220 914 /**
bcostm 0:0002c86c2220 915 * @brief Draws a rectangle in currently active layer.
bcostm 0:0002c86c2220 916 * @param Xpos: X position
bcostm 0:0002c86c2220 917 * @param Ypos: Y position
bcostm 0:0002c86c2220 918 * @param Width: Rectangle width
bcostm 0:0002c86c2220 919 * @param Height: Rectangle height
bcostm 0:0002c86c2220 920 */
bcostm 0:0002c86c2220 921 void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:0002c86c2220 922 {
bcostm 0:0002c86c2220 923 /* Draw horizontal lines */
bcostm 0:0002c86c2220 924 BSP_LCD_DrawHLine(Xpos, Ypos, Width);
bcostm 0:0002c86c2220 925 BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width);
bcostm 0:0002c86c2220 926
bcostm 0:0002c86c2220 927 /* Draw vertical lines */
bcostm 0:0002c86c2220 928 BSP_LCD_DrawVLine(Xpos, Ypos, Height);
bcostm 0:0002c86c2220 929 BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height);
bcostm 0:0002c86c2220 930 }
bcostm 0:0002c86c2220 931
bcostm 0:0002c86c2220 932 /**
bcostm 0:0002c86c2220 933 * @brief Draws a circle in currently active layer.
bcostm 0:0002c86c2220 934 * @param Xpos: X position
bcostm 0:0002c86c2220 935 * @param Ypos: Y position
bcostm 0:0002c86c2220 936 * @param Radius: Circle radius
bcostm 0:0002c86c2220 937 */
bcostm 0:0002c86c2220 938 void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
bcostm 0:0002c86c2220 939 {
bcostm 0:0002c86c2220 940 int32_t D; /* Decision Variable */
bcostm 0:0002c86c2220 941 uint32_t CurX; /* Current X Value */
bcostm 0:0002c86c2220 942 uint32_t CurY; /* Current Y Value */
bcostm 0:0002c86c2220 943
bcostm 0:0002c86c2220 944 D = 3 - (Radius << 1);
bcostm 0:0002c86c2220 945 CurX = 0;
bcostm 0:0002c86c2220 946 CurY = Radius;
bcostm 0:0002c86c2220 947
bcostm 0:0002c86c2220 948 while (CurX <= CurY)
bcostm 0:0002c86c2220 949 {
bcostm 0:0002c86c2220 950 BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 951
bcostm 0:0002c86c2220 952 BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 953
bcostm 0:0002c86c2220 954 BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 955
bcostm 0:0002c86c2220 956 BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 957
bcostm 0:0002c86c2220 958 BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 959
bcostm 0:0002c86c2220 960 BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 961
bcostm 0:0002c86c2220 962 BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 963
bcostm 0:0002c86c2220 964 BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 965
bcostm 0:0002c86c2220 966 if (D < 0)
bcostm 0:0002c86c2220 967 {
bcostm 0:0002c86c2220 968 D += (CurX << 2) + 6;
bcostm 0:0002c86c2220 969 }
bcostm 0:0002c86c2220 970 else
bcostm 0:0002c86c2220 971 {
bcostm 0:0002c86c2220 972 D += ((CurX - CurY) << 2) + 10;
bcostm 0:0002c86c2220 973 CurY--;
bcostm 0:0002c86c2220 974 }
bcostm 0:0002c86c2220 975 CurX++;
bcostm 0:0002c86c2220 976 }
bcostm 0:0002c86c2220 977 }
bcostm 0:0002c86c2220 978
bcostm 0:0002c86c2220 979 /**
bcostm 0:0002c86c2220 980 * @brief Draws an poly-line (between many points) in currently active layer.
bcostm 0:0002c86c2220 981 * @param Points: Pointer to the points array
bcostm 0:0002c86c2220 982 * @param PointCount: Number of points
bcostm 0:0002c86c2220 983 */
bcostm 0:0002c86c2220 984 void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount)
bcostm 0:0002c86c2220 985 {
bcostm 0:0002c86c2220 986 int16_t X = 0, Y = 0;
bcostm 0:0002c86c2220 987
bcostm 0:0002c86c2220 988 if(PointCount < 2)
bcostm 0:0002c86c2220 989 {
bcostm 0:0002c86c2220 990 return;
bcostm 0:0002c86c2220 991 }
bcostm 0:0002c86c2220 992
bcostm 0:0002c86c2220 993 BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
bcostm 0:0002c86c2220 994
bcostm 0:0002c86c2220 995 while(--PointCount)
bcostm 0:0002c86c2220 996 {
bcostm 0:0002c86c2220 997 X = Points->X;
bcostm 0:0002c86c2220 998 Y = Points->Y;
bcostm 0:0002c86c2220 999 Points++;
bcostm 0:0002c86c2220 1000 BSP_LCD_DrawLine(X, Y, Points->X, Points->Y);
bcostm 0:0002c86c2220 1001 }
bcostm 0:0002c86c2220 1002 }
bcostm 0:0002c86c2220 1003
bcostm 0:0002c86c2220 1004 /**
bcostm 0:0002c86c2220 1005 * @brief Draws an ellipse on LCD in currently active layer.
bcostm 0:0002c86c2220 1006 * @param Xpos: X position
bcostm 0:0002c86c2220 1007 * @param Ypos: Y position
bcostm 0:0002c86c2220 1008 * @param XRadius: Ellipse X radius
bcostm 0:0002c86c2220 1009 * @param YRadius: Ellipse Y radius
bcostm 0:0002c86c2220 1010 */
bcostm 0:0002c86c2220 1011 void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
bcostm 0:0002c86c2220 1012 {
bcostm 0:0002c86c2220 1013 int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
bcostm 0:0002c86c2220 1014 float K = 0, rad1 = 0, rad2 = 0;
bcostm 0:0002c86c2220 1015
bcostm 0:0002c86c2220 1016 rad1 = XRadius;
bcostm 0:0002c86c2220 1017 rad2 = YRadius;
bcostm 0:0002c86c2220 1018
bcostm 0:0002c86c2220 1019 K = (float)(rad2/rad1);
bcostm 0:0002c86c2220 1020
bcostm 0:0002c86c2220 1021 do {
bcostm 0:0002c86c2220 1022 BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1023 BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1024 BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1025 BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1026
bcostm 0:0002c86c2220 1027 e2 = err;
bcostm 0:0002c86c2220 1028 if (e2 <= x) {
bcostm 0:0002c86c2220 1029 err += ++x*2+1;
bcostm 0:0002c86c2220 1030 if (-y == x && e2 <= y) e2 = 0;
bcostm 0:0002c86c2220 1031 }
bcostm 0:0002c86c2220 1032 if (e2 > y) err += ++y*2+1;
bcostm 0:0002c86c2220 1033 }
bcostm 0:0002c86c2220 1034 while (y <= 0);
bcostm 0:0002c86c2220 1035 }
bcostm 0:0002c86c2220 1036
bcostm 0:0002c86c2220 1037 /**
bcostm 0:0002c86c2220 1038 * @brief Draws a bitmap picture loaded in the internal Flash (32 bpp) in currently active layer.
bcostm 0:0002c86c2220 1039 * @param Xpos: Bmp X position in the LCD
bcostm 0:0002c86c2220 1040 * @param Ypos: Bmp Y position in the LCD
bcostm 0:0002c86c2220 1041 * @param pbmp: Pointer to Bmp picture address in the internal Flash
bcostm 0:0002c86c2220 1042 */
bcostm 0:0002c86c2220 1043 void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
bcostm 0:0002c86c2220 1044 {
bcostm 0:0002c86c2220 1045 uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
bcostm 0:0002c86c2220 1046 uint32_t Address;
bcostm 0:0002c86c2220 1047 uint32_t InputColorMode = 0;
bcostm 0:0002c86c2220 1048
bcostm 0:0002c86c2220 1049 /* Get bitmap data address offset */
bcostm 0:0002c86c2220 1050 index = *(__IO uint16_t *) (pbmp + 10);
bcostm 0:0002c86c2220 1051 index |= (*(__IO uint16_t *) (pbmp + 12)) << 16;
bcostm 0:0002c86c2220 1052
bcostm 0:0002c86c2220 1053 /* Read bitmap width */
bcostm 0:0002c86c2220 1054 width = *(uint16_t *) (pbmp + 18);
bcostm 0:0002c86c2220 1055 width |= (*(uint16_t *) (pbmp + 20)) << 16;
bcostm 0:0002c86c2220 1056
bcostm 0:0002c86c2220 1057 /* Read bitmap height */
bcostm 0:0002c86c2220 1058 height = *(uint16_t *) (pbmp + 22);
bcostm 0:0002c86c2220 1059 height |= (*(uint16_t *) (pbmp + 24)) << 16;
bcostm 0:0002c86c2220 1060
bcostm 0:0002c86c2220 1061 /* Read bit/pixel */
bcostm 0:0002c86c2220 1062 bit_pixel = *(uint16_t *) (pbmp + 28);
bcostm 0:0002c86c2220 1063
bcostm 0:0002c86c2220 1064 /* Set the address */
bcostm 0:0002c86c2220 1065 Address = hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
bcostm 0:0002c86c2220 1066
bcostm 0:0002c86c2220 1067 /* Get the layer pixel format */
bcostm 0:0002c86c2220 1068 if ((bit_pixel/8) == 4)
bcostm 0:0002c86c2220 1069 {
bcostm 0:0002c86c2220 1070 InputColorMode = CM_ARGB8888;
bcostm 0:0002c86c2220 1071 }
bcostm 0:0002c86c2220 1072 else if ((bit_pixel/8) == 2)
bcostm 0:0002c86c2220 1073 {
bcostm 0:0002c86c2220 1074 InputColorMode = CM_RGB565;
bcostm 0:0002c86c2220 1075 }
bcostm 0:0002c86c2220 1076 else
bcostm 0:0002c86c2220 1077 {
bcostm 0:0002c86c2220 1078 InputColorMode = CM_RGB888;
bcostm 0:0002c86c2220 1079 }
bcostm 0:0002c86c2220 1080
bcostm 0:0002c86c2220 1081 /* Bypass the bitmap header */
bcostm 0:0002c86c2220 1082 pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
bcostm 0:0002c86c2220 1083
bcostm 0:0002c86c2220 1084 /* Convert picture to ARGB8888 pixel format */
bcostm 0:0002c86c2220 1085 for(index=0; index < height; index++)
bcostm 0:0002c86c2220 1086 {
bcostm 0:0002c86c2220 1087 /* Pixel format conversion */
bcostm 0:0002c86c2220 1088 LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode);
bcostm 0:0002c86c2220 1089
bcostm 0:0002c86c2220 1090 /* Increment the source and destination buffers */
bcostm 0:0002c86c2220 1091 Address+= (BSP_LCD_GetXSize()*4);
bcostm 0:0002c86c2220 1092 pbmp -= width*(bit_pixel/8);
bcostm 0:0002c86c2220 1093 }
bcostm 0:0002c86c2220 1094 }
bcostm 0:0002c86c2220 1095
bcostm 0:0002c86c2220 1096 /**
bcostm 0:0002c86c2220 1097 * @brief Draws a full rectangle in currently active layer.
bcostm 0:0002c86c2220 1098 * @param Xpos: X position
bcostm 0:0002c86c2220 1099 * @param Ypos: Y position
bcostm 0:0002c86c2220 1100 * @param Width: Rectangle width
bcostm 0:0002c86c2220 1101 * @param Height: Rectangle height
bcostm 0:0002c86c2220 1102 */
bcostm 0:0002c86c2220 1103 void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:0002c86c2220 1104 {
bcostm 0:0002c86c2220 1105 uint32_t Xaddress = 0;
bcostm 0:0002c86c2220 1106
bcostm 0:0002c86c2220 1107 /* Set the text color */
bcostm 0:0002c86c2220 1108 BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1109
bcostm 0:0002c86c2220 1110 /* Get the rectangle start address */
bcostm 0:0002c86c2220 1111 Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
bcostm 0:0002c86c2220 1112
bcostm 0:0002c86c2220 1113 /* Fill the rectangle */
bcostm 0:0002c86c2220 1114 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1115 }
bcostm 0:0002c86c2220 1116
bcostm 0:0002c86c2220 1117 /**
bcostm 0:0002c86c2220 1118 * @brief Draws a full circle in currently active layer.
bcostm 0:0002c86c2220 1119 * @param Xpos: X position
bcostm 0:0002c86c2220 1120 * @param Ypos: Y position
bcostm 0:0002c86c2220 1121 * @param Radius: Circle radius
bcostm 0:0002c86c2220 1122 */
bcostm 0:0002c86c2220 1123 void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
bcostm 0:0002c86c2220 1124 {
bcostm 0:0002c86c2220 1125 int32_t D; /* Decision Variable */
bcostm 0:0002c86c2220 1126 uint32_t CurX; /* Current X Value */
bcostm 0:0002c86c2220 1127 uint32_t CurY; /* Current Y Value */
bcostm 0:0002c86c2220 1128
bcostm 0:0002c86c2220 1129 D = 3 - (Radius << 1);
bcostm 0:0002c86c2220 1130
bcostm 0:0002c86c2220 1131 CurX = 0;
bcostm 0:0002c86c2220 1132 CurY = Radius;
bcostm 0:0002c86c2220 1133
bcostm 0:0002c86c2220 1134 BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1135
bcostm 0:0002c86c2220 1136 while (CurX <= CurY)
bcostm 0:0002c86c2220 1137 {
bcostm 0:0002c86c2220 1138 if(CurY > 0)
bcostm 0:0002c86c2220 1139 {
bcostm 0:0002c86c2220 1140 BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY);
bcostm 0:0002c86c2220 1141 BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY);
bcostm 0:0002c86c2220 1142 }
bcostm 0:0002c86c2220 1143
bcostm 0:0002c86c2220 1144 if(CurX > 0)
bcostm 0:0002c86c2220 1145 {
bcostm 0:0002c86c2220 1146 BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX);
bcostm 0:0002c86c2220 1147 BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX);
bcostm 0:0002c86c2220 1148 }
bcostm 0:0002c86c2220 1149 if (D < 0)
bcostm 0:0002c86c2220 1150 {
bcostm 0:0002c86c2220 1151 D += (CurX << 2) + 6;
bcostm 0:0002c86c2220 1152 }
bcostm 0:0002c86c2220 1153 else
bcostm 0:0002c86c2220 1154 {
bcostm 0:0002c86c2220 1155 D += ((CurX - CurY) << 2) + 10;
bcostm 0:0002c86c2220 1156 CurY--;
bcostm 0:0002c86c2220 1157 }
bcostm 0:0002c86c2220 1158 CurX++;
bcostm 0:0002c86c2220 1159 }
bcostm 0:0002c86c2220 1160
bcostm 0:0002c86c2220 1161 BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1162 BSP_LCD_DrawCircle(Xpos, Ypos, Radius);
bcostm 0:0002c86c2220 1163 }
bcostm 0:0002c86c2220 1164
bcostm 0:0002c86c2220 1165 /**
bcostm 0:0002c86c2220 1166 * @brief Draws a full poly-line (between many points) in currently active layer.
bcostm 0:0002c86c2220 1167 * @param Points: Pointer to the points array
bcostm 0:0002c86c2220 1168 * @param PointCount: Number of points
bcostm 0:0002c86c2220 1169 */
bcostm 0:0002c86c2220 1170 void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount)
bcostm 0:0002c86c2220 1171 {
bcostm 0:0002c86c2220 1172 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;
bcostm 0:0002c86c2220 1173 uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0;
bcostm 0:0002c86c2220 1174
bcostm 0:0002c86c2220 1175 IMAGE_LEFT = IMAGE_RIGHT = Points->X;
bcostm 0:0002c86c2220 1176 IMAGE_TOP= IMAGE_BOTTOM = Points->Y;
bcostm 0:0002c86c2220 1177
bcostm 0:0002c86c2220 1178 for(counter = 1; counter < PointCount; counter++)
bcostm 0:0002c86c2220 1179 {
bcostm 0:0002c86c2220 1180 pixelX = POLY_X(counter);
bcostm 0:0002c86c2220 1181 if(pixelX < IMAGE_LEFT)
bcostm 0:0002c86c2220 1182 {
bcostm 0:0002c86c2220 1183 IMAGE_LEFT = pixelX;
bcostm 0:0002c86c2220 1184 }
bcostm 0:0002c86c2220 1185 if(pixelX > IMAGE_RIGHT)
bcostm 0:0002c86c2220 1186 {
bcostm 0:0002c86c2220 1187 IMAGE_RIGHT = pixelX;
bcostm 0:0002c86c2220 1188 }
bcostm 0:0002c86c2220 1189
bcostm 0:0002c86c2220 1190 pixelY = POLY_Y(counter);
bcostm 0:0002c86c2220 1191 if(pixelY < IMAGE_TOP)
bcostm 0:0002c86c2220 1192 {
bcostm 0:0002c86c2220 1193 IMAGE_TOP = pixelY;
bcostm 0:0002c86c2220 1194 }
bcostm 0:0002c86c2220 1195 if(pixelY > IMAGE_BOTTOM)
bcostm 0:0002c86c2220 1196 {
bcostm 0:0002c86c2220 1197 IMAGE_BOTTOM = pixelY;
bcostm 0:0002c86c2220 1198 }
bcostm 0:0002c86c2220 1199 }
bcostm 0:0002c86c2220 1200
bcostm 0:0002c86c2220 1201 if(PointCount < 2)
bcostm 0:0002c86c2220 1202 {
bcostm 0:0002c86c2220 1203 return;
bcostm 0:0002c86c2220 1204 }
bcostm 0:0002c86c2220 1205
bcostm 0:0002c86c2220 1206 X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2;
bcostm 0:0002c86c2220 1207 Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2;
bcostm 0:0002c86c2220 1208
bcostm 0:0002c86c2220 1209 X_first = Points->X;
bcostm 0:0002c86c2220 1210 Y_first = Points->Y;
bcostm 0:0002c86c2220 1211
bcostm 0:0002c86c2220 1212 while(--PointCount)
bcostm 0:0002c86c2220 1213 {
bcostm 0:0002c86c2220 1214 X = Points->X;
bcostm 0:0002c86c2220 1215 Y = Points->Y;
bcostm 0:0002c86c2220 1216 Points++;
bcostm 0:0002c86c2220 1217 X2 = Points->X;
bcostm 0:0002c86c2220 1218 Y2 = Points->Y;
bcostm 0:0002c86c2220 1219
bcostm 0:0002c86c2220 1220 FillTriangle(X, X2, X_center, Y, Y2, Y_center);
bcostm 0:0002c86c2220 1221 FillTriangle(X, X_center, X2, Y, Y_center, Y2);
bcostm 0:0002c86c2220 1222 FillTriangle(X_center, X2, X, Y_center, Y2, Y);
bcostm 0:0002c86c2220 1223 }
bcostm 0:0002c86c2220 1224
bcostm 0:0002c86c2220 1225 FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center);
bcostm 0:0002c86c2220 1226 FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2);
bcostm 0:0002c86c2220 1227 FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first);
bcostm 0:0002c86c2220 1228 }
bcostm 0:0002c86c2220 1229
bcostm 0:0002c86c2220 1230 /**
bcostm 0:0002c86c2220 1231 * @brief Draws a full ellipse in currently active layer.
bcostm 0:0002c86c2220 1232 * @param Xpos: X position
bcostm 0:0002c86c2220 1233 * @param Ypos: Y position
bcostm 0:0002c86c2220 1234 * @param XRadius: Ellipse X radius
bcostm 0:0002c86c2220 1235 * @param YRadius: Ellipse Y radius
bcostm 0:0002c86c2220 1236 */
bcostm 0:0002c86c2220 1237 void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
bcostm 0:0002c86c2220 1238 {
bcostm 0:0002c86c2220 1239 int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
bcostm 0:0002c86c2220 1240 float K = 0, rad1 = 0, rad2 = 0;
bcostm 0:0002c86c2220 1241
bcostm 0:0002c86c2220 1242 rad1 = XRadius;
bcostm 0:0002c86c2220 1243 rad2 = YRadius;
bcostm 0:0002c86c2220 1244
bcostm 0:0002c86c2220 1245 K = (float)(rad2/rad1);
bcostm 0:0002c86c2220 1246
bcostm 0:0002c86c2220 1247 do
bcostm 0:0002c86c2220 1248 {
bcostm 0:0002c86c2220 1249 BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1));
bcostm 0:0002c86c2220 1250 BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1));
bcostm 0:0002c86c2220 1251
bcostm 0:0002c86c2220 1252 e2 = err;
bcostm 0:0002c86c2220 1253 if (e2 <= x)
bcostm 0:0002c86c2220 1254 {
bcostm 0:0002c86c2220 1255 err += ++x*2+1;
bcostm 0:0002c86c2220 1256 if (-y == x && e2 <= y) e2 = 0;
bcostm 0:0002c86c2220 1257 }
bcostm 0:0002c86c2220 1258 if (e2 > y) err += ++y*2+1;
bcostm 0:0002c86c2220 1259 }
bcostm 0:0002c86c2220 1260 while (y <= 0);
bcostm 0:0002c86c2220 1261 }
bcostm 0:0002c86c2220 1262
bcostm 0:0002c86c2220 1263 /**
bcostm 0:0002c86c2220 1264 * @brief Switch back on the display if was switched off by previous call of BSP_LCD_DisplayOff().
bcostm 0:0002c86c2220 1265 * Exit DSI ULPM mode if was allowed and configured in Dsi Configuration.
bcostm 0:0002c86c2220 1266 */
bcostm 0:0002c86c2220 1267 void BSP_LCD_DisplayOn(void)
bcostm 0:0002c86c2220 1268 {
bcostm 0:0002c86c2220 1269 /* Send Display on DCS command to display */
bcostm 0:0002c86c2220 1270 HAL_DSI_ShortWrite(&(hdsi_eval),
bcostm 0:0002c86c2220 1271 hdsivideo_handle.VirtualChannelID,
bcostm 0:0002c86c2220 1272 DSI_DCS_SHORT_PKT_WRITE_P1,
bcostm 0:0002c86c2220 1273 OTM8009A_CMD_DISPON,
bcostm 0:0002c86c2220 1274 0x00);
bcostm 0:0002c86c2220 1275
bcostm 0:0002c86c2220 1276 }
bcostm 0:0002c86c2220 1277
bcostm 0:0002c86c2220 1278 /**
bcostm 0:0002c86c2220 1279 * @brief Switch Off the display.
bcostm 0:0002c86c2220 1280 * Enter DSI ULPM mode if was allowed and configured in Dsi Configuration.
bcostm 0:0002c86c2220 1281 */
bcostm 0:0002c86c2220 1282 void BSP_LCD_DisplayOff(void)
bcostm 0:0002c86c2220 1283 {
bcostm 0:0002c86c2220 1284 /* Send Display off DCS Command to display */
bcostm 0:0002c86c2220 1285 HAL_DSI_ShortWrite(&(hdsi_eval),
bcostm 0:0002c86c2220 1286 hdsivideo_handle.VirtualChannelID,
bcostm 0:0002c86c2220 1287 DSI_DCS_SHORT_PKT_WRITE_P1,
bcostm 0:0002c86c2220 1288 OTM8009A_CMD_DISPOFF,
bcostm 0:0002c86c2220 1289 0x00);
bcostm 0:0002c86c2220 1290
bcostm 0:0002c86c2220 1291 }
bcostm 0:0002c86c2220 1292
bcostm 0:0002c86c2220 1293 /**
bcostm 0:0002c86c2220 1294 * @brief DCS or Generic short/long write command
bcostm 0:0002c86c2220 1295 * @param NbParams: Number of parameters. It indicates the write command mode:
bcostm 0:0002c86c2220 1296 * If inferior to 2, a long write command is performed else short.
bcostm 0:0002c86c2220 1297 * @param pParams: Pointer to parameter values table.
bcostm 0:0002c86c2220 1298 * @retval HAL status
bcostm 0:0002c86c2220 1299 */
bcostm 0:0002c86c2220 1300 void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams)
bcostm 0:0002c86c2220 1301 {
bcostm 0:0002c86c2220 1302 if(NbrParams <= 1)
bcostm 0:0002c86c2220 1303 {
bcostm 0:0002c86c2220 1304 HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]);
bcostm 0:0002c86c2220 1305 }
bcostm 0:0002c86c2220 1306 else
bcostm 0:0002c86c2220 1307 {
bcostm 0:0002c86c2220 1308 HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams);
bcostm 0:0002c86c2220 1309 }
bcostm 0:0002c86c2220 1310 }
bcostm 0:0002c86c2220 1311
bcostm 0:0002c86c2220 1312 /*******************************************************************************
bcostm 0:0002c86c2220 1313 LTDC, DMA2D and DSI BSP Routines
bcostm 0:0002c86c2220 1314 *******************************************************************************/
bcostm 0:0002c86c2220 1315 /**
bcostm 0:0002c86c2220 1316 * @brief Handles DMA2D interrupt request.
bcostm 0:0002c86c2220 1317 * @note : Can be surcharged by application code implementation of the function.
bcostm 0:0002c86c2220 1318 */
bcostm 0:0002c86c2220 1319 __weak void BSP_LCD_DMA2D_IRQHandler(void)
bcostm 0:0002c86c2220 1320 {
bcostm 0:0002c86c2220 1321 HAL_DMA2D_IRQHandler(&hdma2d_eval);
bcostm 0:0002c86c2220 1322 }
bcostm 0:0002c86c2220 1323
bcostm 0:0002c86c2220 1324 /**
bcostm 0:0002c86c2220 1325 * @brief Handles DSI interrupt request.
bcostm 0:0002c86c2220 1326 * @note : Can be surcharged by application code implementation of the function.
bcostm 0:0002c86c2220 1327 */
bcostm 0:0002c86c2220 1328 __weak void BSP_LCD_DSI_IRQHandler(void)
bcostm 0:0002c86c2220 1329 {
bcostm 0:0002c86c2220 1330 HAL_DSI_IRQHandler(&(hdsi_eval));
bcostm 0:0002c86c2220 1331 }
bcostm 0:0002c86c2220 1332
bcostm 0:0002c86c2220 1333
bcostm 0:0002c86c2220 1334 /**
bcostm 0:0002c86c2220 1335 * @brief Handles LTDC interrupt request.
bcostm 0:0002c86c2220 1336 * @note : Can be surcharged by application code implementation of the function.
bcostm 0:0002c86c2220 1337 */
bcostm 0:0002c86c2220 1338 __weak void BSP_LCD_LTDC_IRQHandler(void)
bcostm 0:0002c86c2220 1339 {
bcostm 0:0002c86c2220 1340 HAL_LTDC_IRQHandler(&(hltdc_eval));
bcostm 0:0002c86c2220 1341 }
bcostm 0:0002c86c2220 1342
bcostm 0:0002c86c2220 1343 /**
bcostm 0:0002c86c2220 1344 * @brief De-Initializes the BSP LCD Msp
bcostm 0:0002c86c2220 1345 * Application can surcharge if needed this function implementation.
bcostm 0:0002c86c2220 1346 */
bcostm 0:0002c86c2220 1347 __weak void BSP_LCD_MspDeInit(void)
bcostm 0:0002c86c2220 1348 {
bcostm 0:0002c86c2220 1349 /** @brief Disable IRQ of LTDC IP */
bcostm 0:0002c86c2220 1350 HAL_NVIC_DisableIRQ(LTDC_IRQn);
bcostm 0:0002c86c2220 1351
bcostm 0:0002c86c2220 1352 /** @brief Disable IRQ of DMA2D IP */
bcostm 0:0002c86c2220 1353 HAL_NVIC_DisableIRQ(DMA2D_IRQn);
bcostm 0:0002c86c2220 1354
bcostm 0:0002c86c2220 1355 /** @brief Disable IRQ of DSI IP */
bcostm 0:0002c86c2220 1356 HAL_NVIC_DisableIRQ(DSI_IRQn);
bcostm 0:0002c86c2220 1357
bcostm 0:0002c86c2220 1358 /** @brief Force and let in reset state LTDC, DMA2D and DSI Host + Wrapper IPs */
bcostm 0:0002c86c2220 1359 __HAL_RCC_LTDC_FORCE_RESET();
bcostm 0:0002c86c2220 1360 __HAL_RCC_DMA2D_FORCE_RESET();
bcostm 0:0002c86c2220 1361 __HAL_RCC_DSI_FORCE_RESET();
bcostm 0:0002c86c2220 1362
bcostm 0:0002c86c2220 1363 /** @brief Disable the LTDC, DMA2D and DSI Host and Wrapper clocks */
bcostm 0:0002c86c2220 1364 __HAL_RCC_LTDC_CLK_DISABLE();
bcostm 0:0002c86c2220 1365 __HAL_RCC_DMA2D_CLK_DISABLE();
bcostm 0:0002c86c2220 1366 __HAL_RCC_DSI_CLK_DISABLE();
bcostm 0:0002c86c2220 1367 }
bcostm 0:0002c86c2220 1368
bcostm 0:0002c86c2220 1369 /**
bcostm 0:0002c86c2220 1370 * @brief Initialize the BSP LCD Msp.
bcostm 0:0002c86c2220 1371 * Application can surcharge if needed this function implementation
bcostm 0:0002c86c2220 1372 */
bcostm 0:0002c86c2220 1373 __weak void BSP_LCD_MspInit(void)
bcostm 0:0002c86c2220 1374 {
bcostm 0:0002c86c2220 1375 /** @brief Enable the LTDC clock */
bcostm 0:0002c86c2220 1376 __HAL_RCC_LTDC_CLK_ENABLE();
bcostm 0:0002c86c2220 1377
bcostm 0:0002c86c2220 1378 /** @brief Toggle Sw reset of LTDC IP */
bcostm 0:0002c86c2220 1379 __HAL_RCC_LTDC_FORCE_RESET();
bcostm 0:0002c86c2220 1380 __HAL_RCC_LTDC_RELEASE_RESET();
bcostm 0:0002c86c2220 1381
bcostm 0:0002c86c2220 1382 /** @brief Enable the DMA2D clock */
bcostm 0:0002c86c2220 1383 __HAL_RCC_DMA2D_CLK_ENABLE();
bcostm 0:0002c86c2220 1384
bcostm 0:0002c86c2220 1385 /** @brief Toggle Sw reset of DMA2D IP */
bcostm 0:0002c86c2220 1386 __HAL_RCC_DMA2D_FORCE_RESET();
bcostm 0:0002c86c2220 1387 __HAL_RCC_DMA2D_RELEASE_RESET();
bcostm 0:0002c86c2220 1388
bcostm 0:0002c86c2220 1389 /** @brief Enable DSI Host and wrapper clocks */
bcostm 0:0002c86c2220 1390 __HAL_RCC_DSI_CLK_ENABLE();
bcostm 0:0002c86c2220 1391
bcostm 0:0002c86c2220 1392 /** @brief Soft Reset the DSI Host and wrapper */
bcostm 0:0002c86c2220 1393 __HAL_RCC_DSI_FORCE_RESET();
bcostm 0:0002c86c2220 1394 __HAL_RCC_DSI_RELEASE_RESET();
bcostm 0:0002c86c2220 1395
bcostm 0:0002c86c2220 1396 /** @brief NVIC configuration for LTDC interrupt that is now enabled */
bcostm 0:0002c86c2220 1397 HAL_NVIC_SetPriority(LTDC_IRQn, 3, 0);
bcostm 0:0002c86c2220 1398 HAL_NVIC_EnableIRQ(LTDC_IRQn);
bcostm 0:0002c86c2220 1399
bcostm 0:0002c86c2220 1400 /** @brief NVIC configuration for DMA2D interrupt that is now enabled */
bcostm 0:0002c86c2220 1401 HAL_NVIC_SetPriority(DMA2D_IRQn, 3, 0);
bcostm 0:0002c86c2220 1402 HAL_NVIC_EnableIRQ(DMA2D_IRQn);
bcostm 0:0002c86c2220 1403
bcostm 0:0002c86c2220 1404 /** @brief NVIC configuration for DSI interrupt that is now enabled */
bcostm 0:0002c86c2220 1405 HAL_NVIC_SetPriority(DSI_IRQn, 3, 0);
bcostm 0:0002c86c2220 1406 HAL_NVIC_EnableIRQ(DSI_IRQn);
bcostm 0:0002c86c2220 1407 }
bcostm 0:0002c86c2220 1408
bcostm 0:0002c86c2220 1409 /**
bcostm 0:0002c86c2220 1410 * @brief This function handles LTDC Error interrupt Handler.
bcostm 0:0002c86c2220 1411 * @note : Can be surcharged by application code implementation of the function.
bcostm 0:0002c86c2220 1412 */
bcostm 0:0002c86c2220 1413
bcostm 0:0002c86c2220 1414 __weak void BSP_LCD_LTDC_ER_IRQHandler(void)
bcostm 0:0002c86c2220 1415 {
bcostm 0:0002c86c2220 1416 HAL_LTDC_IRQHandler(&(hltdc_eval));
bcostm 0:0002c86c2220 1417 }
bcostm 0:0002c86c2220 1418
bcostm 0:0002c86c2220 1419
bcostm 0:0002c86c2220 1420 /**
bcostm 0:0002c86c2220 1421 * @brief Draws a pixel on LCD.
bcostm 0:0002c86c2220 1422 * @param Xpos: X position
bcostm 0:0002c86c2220 1423 * @param Ypos: Y position
bcostm 0:0002c86c2220 1424 * @param RGB_Code: Pixel color in ARGB mode (8-8-8-8)
bcostm 0:0002c86c2220 1425 */
bcostm 0:0002c86c2220 1426 void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
bcostm 0:0002c86c2220 1427 {
bcostm 0:0002c86c2220 1428 /* Write data value to all SDRAM memory */
bcostm 0:0002c86c2220 1429 *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code;
bcostm 0:0002c86c2220 1430 }
bcostm 0:0002c86c2220 1431
bcostm 0:0002c86c2220 1432
bcostm 0:0002c86c2220 1433 /**
bcostm 0:0002c86c2220 1434 * @brief Draws a character on LCD.
bcostm 0:0002c86c2220 1435 * @param Xpos: Line where to display the character shape
bcostm 0:0002c86c2220 1436 * @param Ypos: Start column address
bcostm 0:0002c86c2220 1437 * @param c: Pointer to the character data
bcostm 0:0002c86c2220 1438 */
bcostm 0:0002c86c2220 1439 static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c)
bcostm 0:0002c86c2220 1440 {
bcostm 0:0002c86c2220 1441 uint32_t i = 0, j = 0;
bcostm 0:0002c86c2220 1442 uint16_t height, width;
bcostm 0:0002c86c2220 1443 uint8_t offset;
bcostm 0:0002c86c2220 1444 uint8_t *pchar;
bcostm 0:0002c86c2220 1445 uint32_t line;
bcostm 0:0002c86c2220 1446
bcostm 0:0002c86c2220 1447 height = DrawProp[ActiveLayer].pFont->Height;
bcostm 0:0002c86c2220 1448 width = DrawProp[ActiveLayer].pFont->Width;
bcostm 0:0002c86c2220 1449
bcostm 0:0002c86c2220 1450 offset = 8 *((width + 7)/8) - width ;
bcostm 0:0002c86c2220 1451
bcostm 0:0002c86c2220 1452 for(i = 0; i < height; i++)
bcostm 0:0002c86c2220 1453 {
bcostm 0:0002c86c2220 1454 pchar = ((uint8_t *)c + (width + 7)/8 * i);
bcostm 0:0002c86c2220 1455
bcostm 0:0002c86c2220 1456 switch(((width + 7)/8))
bcostm 0:0002c86c2220 1457 {
bcostm 0:0002c86c2220 1458
bcostm 0:0002c86c2220 1459 case 1:
bcostm 0:0002c86c2220 1460 line = pchar[0];
bcostm 0:0002c86c2220 1461 break;
bcostm 0:0002c86c2220 1462
bcostm 0:0002c86c2220 1463 case 2:
bcostm 0:0002c86c2220 1464 line = (pchar[0]<< 8) | pchar[1];
bcostm 0:0002c86c2220 1465 break;
bcostm 0:0002c86c2220 1466
bcostm 0:0002c86c2220 1467 case 3:
bcostm 0:0002c86c2220 1468 default:
bcostm 0:0002c86c2220 1469 line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];
bcostm 0:0002c86c2220 1470 break;
bcostm 0:0002c86c2220 1471 }
bcostm 0:0002c86c2220 1472
bcostm 0:0002c86c2220 1473 for (j = 0; j < width; j++)
bcostm 0:0002c86c2220 1474 {
bcostm 0:0002c86c2220 1475 if(line & (1 << (width- j + offset- 1)))
bcostm 0:0002c86c2220 1476 {
bcostm 0:0002c86c2220 1477 BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor);
bcostm 0:0002c86c2220 1478 }
bcostm 0:0002c86c2220 1479 else
bcostm 0:0002c86c2220 1480 {
bcostm 0:0002c86c2220 1481 BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor);
bcostm 0:0002c86c2220 1482 }
bcostm 0:0002c86c2220 1483 }
bcostm 0:0002c86c2220 1484 Ypos++;
bcostm 0:0002c86c2220 1485 }
bcostm 0:0002c86c2220 1486 }
bcostm 0:0002c86c2220 1487
bcostm 0:0002c86c2220 1488 /**
bcostm 0:0002c86c2220 1489 * @brief Fills a triangle (between 3 points).
bcostm 0:0002c86c2220 1490 * @param x1: Point 1 X position
bcostm 0:0002c86c2220 1491 * @param y1: Point 1 Y position
bcostm 0:0002c86c2220 1492 * @param x2: Point 2 X position
bcostm 0:0002c86c2220 1493 * @param y2: Point 2 Y position
bcostm 0:0002c86c2220 1494 * @param x3: Point 3 X position
bcostm 0:0002c86c2220 1495 * @param y3: Point 3 Y position
bcostm 0:0002c86c2220 1496 */
bcostm 0:0002c86c2220 1497 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
bcostm 0:0002c86c2220 1498 {
bcostm 0:0002c86c2220 1499 int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
bcostm 0:0002c86c2220 1500 yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
bcostm 0:0002c86c2220 1501 curpixel = 0;
bcostm 0:0002c86c2220 1502
bcostm 0:0002c86c2220 1503 deltax = ABS(x2 - x1); /* The difference between the x's */
bcostm 0:0002c86c2220 1504 deltay = ABS(y2 - y1); /* The difference between the y's */
bcostm 0:0002c86c2220 1505 x = x1; /* Start x off at the first pixel */
bcostm 0:0002c86c2220 1506 y = y1; /* Start y off at the first pixel */
bcostm 0:0002c86c2220 1507
bcostm 0:0002c86c2220 1508 if (x2 >= x1) /* The x-values are increasing */
bcostm 0:0002c86c2220 1509 {
bcostm 0:0002c86c2220 1510 xinc1 = 1;
bcostm 0:0002c86c2220 1511 xinc2 = 1;
bcostm 0:0002c86c2220 1512 }
bcostm 0:0002c86c2220 1513 else /* The x-values are decreasing */
bcostm 0:0002c86c2220 1514 {
bcostm 0:0002c86c2220 1515 xinc1 = -1;
bcostm 0:0002c86c2220 1516 xinc2 = -1;
bcostm 0:0002c86c2220 1517 }
bcostm 0:0002c86c2220 1518
bcostm 0:0002c86c2220 1519 if (y2 >= y1) /* The y-values are increasing */
bcostm 0:0002c86c2220 1520 {
bcostm 0:0002c86c2220 1521 yinc1 = 1;
bcostm 0:0002c86c2220 1522 yinc2 = 1;
bcostm 0:0002c86c2220 1523 }
bcostm 0:0002c86c2220 1524 else /* The y-values are decreasing */
bcostm 0:0002c86c2220 1525 {
bcostm 0:0002c86c2220 1526 yinc1 = -1;
bcostm 0:0002c86c2220 1527 yinc2 = -1;
bcostm 0:0002c86c2220 1528 }
bcostm 0:0002c86c2220 1529
bcostm 0:0002c86c2220 1530 if (deltax >= deltay) /* There is at least one x-value for every y-value */
bcostm 0:0002c86c2220 1531 {
bcostm 0:0002c86c2220 1532 xinc1 = 0; /* Don't change the x when numerator >= denominator */
bcostm 0:0002c86c2220 1533 yinc2 = 0; /* Don't change the y for every iteration */
bcostm 0:0002c86c2220 1534 den = deltax;
bcostm 0:0002c86c2220 1535 num = deltax / 2;
bcostm 0:0002c86c2220 1536 numadd = deltay;
bcostm 0:0002c86c2220 1537 numpixels = deltax; /* There are more x-values than y-values */
bcostm 0:0002c86c2220 1538 }
bcostm 0:0002c86c2220 1539 else /* There is at least one y-value for every x-value */
bcostm 0:0002c86c2220 1540 {
bcostm 0:0002c86c2220 1541 xinc2 = 0; /* Don't change the x for every iteration */
bcostm 0:0002c86c2220 1542 yinc1 = 0; /* Don't change the y when numerator >= denominator */
bcostm 0:0002c86c2220 1543 den = deltay;
bcostm 0:0002c86c2220 1544 num = deltay / 2;
bcostm 0:0002c86c2220 1545 numadd = deltax;
bcostm 0:0002c86c2220 1546 numpixels = deltay; /* There are more y-values than x-values */
bcostm 0:0002c86c2220 1547 }
bcostm 0:0002c86c2220 1548
bcostm 0:0002c86c2220 1549 for (curpixel = 0; curpixel <= numpixels; curpixel++)
bcostm 0:0002c86c2220 1550 {
bcostm 0:0002c86c2220 1551 BSP_LCD_DrawLine(x, y, x3, y3);
bcostm 0:0002c86c2220 1552
bcostm 0:0002c86c2220 1553 num += numadd; /* Increase the numerator by the top of the fraction */
bcostm 0:0002c86c2220 1554 if (num >= den) /* Check if numerator >= denominator */
bcostm 0:0002c86c2220 1555 {
bcostm 0:0002c86c2220 1556 num -= den; /* Calculate the new numerator value */
bcostm 0:0002c86c2220 1557 x += xinc1; /* Change the x as appropriate */
bcostm 0:0002c86c2220 1558 y += yinc1; /* Change the y as appropriate */
bcostm 0:0002c86c2220 1559 }
bcostm 0:0002c86c2220 1560 x += xinc2; /* Change the x as appropriate */
bcostm 0:0002c86c2220 1561 y += yinc2; /* Change the y as appropriate */
bcostm 0:0002c86c2220 1562 }
bcostm 0:0002c86c2220 1563 }
bcostm 0:0002c86c2220 1564
bcostm 0:0002c86c2220 1565 /**
bcostm 0:0002c86c2220 1566 * @brief Fills a buffer.
bcostm 0:0002c86c2220 1567 * @param LayerIndex: Layer index
bcostm 0:0002c86c2220 1568 * @param pDst: Pointer to destination buffer
bcostm 0:0002c86c2220 1569 * @param xSize: Buffer width
bcostm 0:0002c86c2220 1570 * @param ySize: Buffer height
bcostm 0:0002c86c2220 1571 * @param OffLine: Offset
bcostm 0:0002c86c2220 1572 * @param ColorIndex: Color index
bcostm 0:0002c86c2220 1573 */
bcostm 0:0002c86c2220 1574 static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex)
bcostm 0:0002c86c2220 1575 {
bcostm 0:0002c86c2220 1576 /* Register to memory mode with ARGB8888 as color Mode */
bcostm 0:0002c86c2220 1577 hdma2d_eval.Init.Mode = DMA2D_R2M;
bcostm 0:0002c86c2220 1578 hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888;
bcostm 0:0002c86c2220 1579 hdma2d_eval.Init.OutputOffset = OffLine;
bcostm 0:0002c86c2220 1580
bcostm 0:0002c86c2220 1581 hdma2d_eval.Instance = DMA2D;
bcostm 0:0002c86c2220 1582
bcostm 0:0002c86c2220 1583 /* DMA2D Initialization */
bcostm 0:0002c86c2220 1584 if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)
bcostm 0:0002c86c2220 1585 {
bcostm 0:0002c86c2220 1586 if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, LayerIndex) == HAL_OK)
bcostm 0:0002c86c2220 1587 {
bcostm 0:0002c86c2220 1588 if (HAL_DMA2D_Start(&hdma2d_eval, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK)
bcostm 0:0002c86c2220 1589 {
bcostm 0:0002c86c2220 1590 /* Polling For DMA transfer */
bcostm 0:0002c86c2220 1591 HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10);
bcostm 0:0002c86c2220 1592 }
bcostm 0:0002c86c2220 1593 }
bcostm 0:0002c86c2220 1594 }
bcostm 0:0002c86c2220 1595 }
bcostm 0:0002c86c2220 1596
bcostm 0:0002c86c2220 1597 /**
bcostm 0:0002c86c2220 1598 * @brief Converts a line to an ARGB8888 pixel format.
bcostm 0:0002c86c2220 1599 * @param pSrc: Pointer to source buffer
bcostm 0:0002c86c2220 1600 * @param pDst: Output color
bcostm 0:0002c86c2220 1601 * @param xSize: Buffer width
bcostm 0:0002c86c2220 1602 * @param ColorMode: Input color mode
bcostm 0:0002c86c2220 1603 */
bcostm 0:0002c86c2220 1604 static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode)
bcostm 0:0002c86c2220 1605 {
bcostm 0:0002c86c2220 1606 /* Configure the DMA2D Mode, Color Mode and output offset */
bcostm 0:0002c86c2220 1607 hdma2d_eval.Init.Mode = DMA2D_M2M_PFC;
bcostm 0:0002c86c2220 1608 hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888;
bcostm 0:0002c86c2220 1609 hdma2d_eval.Init.OutputOffset = 0;
bcostm 0:0002c86c2220 1610
bcostm 0:0002c86c2220 1611 /* Foreground Configuration */
bcostm 0:0002c86c2220 1612 hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
bcostm 0:0002c86c2220 1613 hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF;
bcostm 0:0002c86c2220 1614 hdma2d_eval.LayerCfg[1].InputColorMode = ColorMode;
bcostm 0:0002c86c2220 1615 hdma2d_eval.LayerCfg[1].InputOffset = 0;
bcostm 0:0002c86c2220 1616
bcostm 0:0002c86c2220 1617 hdma2d_eval.Instance = DMA2D;
bcostm 0:0002c86c2220 1618
bcostm 0:0002c86c2220 1619 /* DMA2D Initialization */
bcostm 0:0002c86c2220 1620 if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)
bcostm 0:0002c86c2220 1621 {
bcostm 0:0002c86c2220 1622 if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK)
bcostm 0:0002c86c2220 1623 {
bcostm 0:0002c86c2220 1624 if (HAL_DMA2D_Start(&hdma2d_eval, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK)
bcostm 0:0002c86c2220 1625 {
bcostm 0:0002c86c2220 1626 /* Polling For DMA transfer */
bcostm 0:0002c86c2220 1627 HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10);
bcostm 0:0002c86c2220 1628 }
bcostm 0:0002c86c2220 1629 }
bcostm 0:0002c86c2220 1630 }
bcostm 0:0002c86c2220 1631 }
bcostm 0:0002c86c2220 1632
bcostm 0:0002c86c2220 1633 /**
bcostm 0:0002c86c2220 1634 * @}
bcostm 0:0002c86c2220 1635 */
bcostm 0:0002c86c2220 1636
bcostm 0:0002c86c2220 1637 /**
bcostm 0:0002c86c2220 1638 * @}
bcostm 0:0002c86c2220 1639 */
bcostm 0:0002c86c2220 1640
bcostm 0:0002c86c2220 1641 /**
bcostm 0:0002c86c2220 1642 * @}
bcostm 0:0002c86c2220 1643 */
bcostm 0:0002c86c2220 1644
bcostm 0:0002c86c2220 1645 /**
bcostm 0:0002c86c2220 1646 * @}
bcostm 0:0002c86c2220 1647 */
bcostm 0:0002c86c2220 1648
bcostm 0:0002c86c2220 1649 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/