1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_ltdc.h 4 * @author MCD Application Team 5 * @version V1.5.1 6 * @date 22-May-2015 7 * @brief This file contains all the functions prototypes for the LTDC firmware 8 * library. 9 ****************************************************************************** 10 * @attention 11 * 12 * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> 13 * 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 * You may not use this file except in compliance with the License. 16 * You may obtain a copy of the License at: 17 * 18 * http://www.st.com/software_license_agreement_liberty_v2 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 * 26 ****************************************************************************** 27 */ 28 29 /* Define to prevent recursive inclusion -------------------------------------*/ 30 #ifndef __STM32F4xx_LTDC_H 31 #define __STM32F4xx_LTDC_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Includes ------------------------------------------------------------------*/ 38 #include "stm32f4xx.h" 39 40 /** @addtogroup STM32F4xx_StdPeriph_Driver 41 * @{ 42 */ 43 44 /** @addtogroup LTDC 45 * @{ 46 */ 47 48 /* Exported types ------------------------------------------------------------*/ 49 50 /** 51 * @brief LTDC Init structure definition 52 */ 53 54 typedef struct 55 { 56 uint32_t LTDC_HSPolarity; /*!< configures the horizontal synchronization polarity. 57 This parameter can be one value of @ref LTDC_HSPolarity */ 58 59 uint32_t LTDC_VSPolarity; /*!< configures the vertical synchronization polarity. 60 This parameter can be one value of @ref LTDC_VSPolarity */ 61 62 uint32_t LTDC_DEPolarity; /*!< configures the data enable polarity. This parameter can 63 be one of value of @ref LTDC_DEPolarity */ 64 65 uint32_t LTDC_PCPolarity; /*!< configures the pixel clock polarity. This parameter can 66 be one of value of @ref LTDC_PCPolarity */ 67 68 uint32_t LTDC_HorizontalSync; /*!< configures the number of Horizontal synchronization 69 width. This parameter must range from 0x000 to 0xFFF. */ 70 71 uint32_t LTDC_VerticalSync; /*!< configures the number of Vertical synchronization 72 height. This parameter must range from 0x000 to 0x7FF. */ 73 74 uint32_t LTDC_AccumulatedHBP; /*!< configures the accumulated horizontal back porch width. 75 This parameter must range from LTDC_HorizontalSync to 0xFFF. */ 76 77 uint32_t LTDC_AccumulatedVBP; /*!< configures the accumulated vertical back porch height. 78 This parameter must range from LTDC_VerticalSync to 0x7FF. */ 79 80 uint32_t LTDC_AccumulatedActiveW; /*!< configures the accumulated active width. This parameter 81 must range from LTDC_AccumulatedHBP to 0xFFF. */ 82 83 uint32_t LTDC_AccumulatedActiveH; /*!< configures the accumulated active height. This parameter 84 must range from LTDC_AccumulatedVBP to 0x7FF. */ 85 86 uint32_t LTDC_TotalWidth; /*!< configures the total width. This parameter 87 must range from LTDC_AccumulatedActiveW to 0xFFF. */ 88 89 uint32_t LTDC_TotalHeigh; /*!< configures the total height. This parameter 90 must range from LTDC_AccumulatedActiveH to 0x7FF. */ 91 92 uint32_t LTDC_BackgroundRedValue; /*!< configures the background red value. 93 This parameter must range from 0x00 to 0xFF. */ 94 95 uint32_t LTDC_BackgroundGreenValue; /*!< configures the background green value. 96 This parameter must range from 0x00 to 0xFF. */ 97 98 uint32_t LTDC_BackgroundBlueValue; /*!< configures the background blue value. 99 This parameter must range from 0x00 to 0xFF. */ 100 } LTDC_InitTypeDef; 101 102 /** 103 * @brief LTDC Layer structure definition 104 */ 105 106 typedef struct 107 { 108 uint32_t LTDC_HorizontalStart; /*!< Configures the Window Horizontal Start Position. 109 This parameter must range from 0x000 to 0xFFF. */ 110 111 uint32_t LTDC_HorizontalStop; /*!< Configures the Window Horizontal Stop Position. 112 This parameter must range from 0x0000 to 0xFFFF. */ 113 114 uint32_t LTDC_VerticalStart; /*!< Configures the Window vertical Start Position. 115 This parameter must range from 0x000 to 0xFFF. */ 116 117 uint32_t LTDC_VerticalStop; /*!< Configures the Window vaertical Stop Position. 118 This parameter must range from 0x0000 to 0xFFFF. */ 119 120 uint32_t LTDC_PixelFormat; /*!< Specifies the pixel format. This parameter can be 121 one of value of @ref LTDC_Pixelformat */ 122 123 uint32_t LTDC_ConstantAlpha; /*!< Specifies the constant alpha used for blending. 124 This parameter must range from 0x00 to 0xFF. */ 125 126 uint32_t LTDC_DefaultColorBlue; /*!< Configures the default blue value. 127 This parameter must range from 0x00 to 0xFF. */ 128 129 uint32_t LTDC_DefaultColorGreen; /*!< Configures the default green value. 130 This parameter must range from 0x00 to 0xFF. */ 131 132 uint32_t LTDC_DefaultColorRed; /*!< Configures the default red value. 133 This parameter must range from 0x00 to 0xFF. */ 134 135 uint32_t LTDC_DefaultColorAlpha; /*!< Configures the default alpha value. 136 This parameter must range from 0x00 to 0xFF. */ 137 138 uint32_t LTDC_BlendingFactor_1; /*!< Select the blending factor 1. This parameter 139 can be one of value of @ref LTDC_BlendingFactor1 */ 140 141 uint32_t LTDC_BlendingFactor_2; /*!< Select the blending factor 2. This parameter 142 can be one of value of @ref LTDC_BlendingFactor2 */ 143 144 uint32_t LTDC_CFBStartAdress; /*!< Configures the color frame buffer address */ 145 146 uint32_t LTDC_CFBLineLength; /*!< Configures the color frame buffer line length. 147 This parameter must range from 0x0000 to 0x1FFF. */ 148 149 uint32_t LTDC_CFBPitch; /*!< Configures the color frame buffer pitch in bytes. 150 This parameter must range from 0x0000 to 0x1FFF. */ 151 152 uint32_t LTDC_CFBLineNumber; /*!< Specifies the number of line in frame buffer. 153 This parameter must range from 0x000 to 0x7FF. */ 154 } LTDC_Layer_InitTypeDef; 155 156 /** 157 * @brief LTDC Position structure definition 158 */ 159 160 typedef struct 161 { 162 uint32_t LTDC_POSX; /*!< Current X Position */ 163 uint32_t LTDC_POSY; /*!< Current Y Position */ 164 } LTDC_PosTypeDef; 165 166 typedef struct 167 { 168 uint32_t LTDC_BlueWidth; /*!< Blue width */ 169 uint32_t LTDC_GreenWidth; /*!< Green width */ 170 uint32_t LTDC_RedWidth; /*!< Red width */ 171 } LTDC_RGBTypeDef; 172 173 typedef struct 174 { 175 uint32_t LTDC_ColorKeyBlue; /*!< Configures the color key blue value. 176 This parameter must range from 0x00 to 0xFF. */ 177 178 uint32_t LTDC_ColorKeyGreen; /*!< Configures the color key green value. 179 This parameter must range from 0x00 to 0xFF. */ 180 181 uint32_t LTDC_ColorKeyRed; /*!< Configures the color key red value. 182 This parameter must range from 0x00 to 0xFF. */ 183 } LTDC_ColorKeying_InitTypeDef; 184 185 typedef struct 186 { 187 uint32_t LTDC_CLUTAdress; /*!< Configures the CLUT address. 188 This parameter must range from 0x00 to 0xFF. */ 189 190 uint32_t LTDC_BlueValue; /*!< Configures the blue value. 191 This parameter must range from 0x00 to 0xFF. */ 192 193 uint32_t LTDC_GreenValue; /*!< Configures the green value. 194 This parameter must range from 0x00 to 0xFF. */ 195 196 uint32_t LTDC_RedValue; /*!< Configures the red value. 197 This parameter must range from 0x00 to 0xFF. */ 198 } LTDC_CLUT_InitTypeDef; 199 200 /* Exported constants --------------------------------------------------------*/ 201 202 /** @defgroup LTDC_Exported_Constants 203 * @} 204 */ 205 206 /** @defgroup LTDC_SYNC 207 * @{ 208 */ 209 210 #define LTDC_HorizontalSYNC ((uint32_t)0x00000FFF) 211 #define LTDC_VerticalSYNC ((uint32_t)0x000007FF) 212 213 #define IS_LTDC_HSYNC(HSYNC) ((HSYNC) <= LTDC_HorizontalSYNC) 214 #define IS_LTDC_VSYNC(VSYNC) ((VSYNC) <= LTDC_VerticalSYNC) 215 #define IS_LTDC_AHBP(AHBP) ((AHBP) <= LTDC_HorizontalSYNC) 216 #define IS_LTDC_AVBP(AVBP) ((AVBP) <= LTDC_VerticalSYNC) 217 #define IS_LTDC_AAW(AAW) ((AAW) <= LTDC_HorizontalSYNC) 218 #define IS_LTDC_AAH(AAH) ((AAH) <= LTDC_VerticalSYNC) 219 #define IS_LTDC_TOTALW(TOTALW) ((TOTALW) <= LTDC_HorizontalSYNC) 220 #define IS_LTDC_TOTALH(TOTALH) ((TOTALH) <= LTDC_VerticalSYNC) 221 222 /** 223 * @} 224 */ 225 226 /** @defgroup LTDC_HSPolarity 227 * @{ 228 */ 229 #define LTDC_HSPolarity_AL ((uint32_t)0x00000000) /*!< Horizontal Synchronization is active low. */ 230 #define LTDC_HSPolarity_AH LTDC_GCR_HSPOL /*!< Horizontal Synchronization is active high. */ 231 232 #define IS_LTDC_HSPOL(HSPOL) (((HSPOL) == LTDC_HSPolarity_AL) || \ 233 ((HSPOL) == LTDC_HSPolarity_AH)) 234 235 /** 236 * @} 237 */ 238 239 /** @defgroup LTDC_VSPolarity 240 * @{ 241 */ 242 #define LTDC_VSPolarity_AL ((uint32_t)0x00000000) /*!< Vertical Synchronization is active low. */ 243 #define LTDC_VSPolarity_AH LTDC_GCR_VSPOL /*!< Vertical Synchronization is active high. */ 244 245 #define IS_LTDC_VSPOL(VSPOL) (((VSPOL) == LTDC_VSPolarity_AL) || \ 246 ((VSPOL) == LTDC_VSPolarity_AH)) 247 248 /** 249 * @} 250 */ 251 252 /** @defgroup LTDC_DEPolarity 253 * @{ 254 */ 255 #define LTDC_DEPolarity_AL ((uint32_t)0x00000000) /*!< Data Enable, is active low. */ 256 #define LTDC_DEPolarity_AH LTDC_GCR_DEPOL /*!< Data Enable, is active high. */ 257 258 #define IS_LTDC_DEPOL(DEPOL) (((DEPOL) == LTDC_VSPolarity_AL) || \ 259 ((DEPOL) == LTDC_DEPolarity_AH)) 260 261 /** 262 * @} 263 */ 264 265 /** @defgroup LTDC_PCPolarity 266 * @{ 267 */ 268 #define LTDC_PCPolarity_IPC ((uint32_t)0x00000000) /*!< input pixel clock. */ 269 #define LTDC_PCPolarity_IIPC LTDC_GCR_PCPOL /*!< inverted input pixel clock. */ 270 271 #define IS_LTDC_PCPOL(PCPOL) (((PCPOL) == LTDC_PCPolarity_IPC) || \ 272 ((PCPOL) == LTDC_PCPolarity_IIPC)) 273 274 /** 275 * @} 276 */ 277 278 /** @defgroup LTDC_Reload 279 * @{ 280 */ 281 #define LTDC_IMReload LTDC_SRCR_IMR /*!< Immediately Reload. */ 282 #define LTDC_VBReload LTDC_SRCR_VBR /*!< Vertical Blanking Reload. */ 283 284 #define IS_LTDC_RELOAD(RELOAD) (((RELOAD) == LTDC_IMReload) || \ 285 ((RELOAD) == LTDC_VBReload)) 286 287 /** 288 * @} 289 */ 290 291 /** @defgroup LTDC_Back_Color 292 * @{ 293 */ 294 295 #define LTDC_Back_Color ((uint32_t)0x000000FF) 296 297 #define IS_LTDC_BackBlueValue(BBLUE) ((BBLUE) <= LTDC_Back_Color) 298 #define IS_LTDC_BackGreenValue(BGREEN) ((BGREEN) <= LTDC_Back_Color) 299 #define IS_LTDC_BackRedValue(BRED) ((BRED) <= LTDC_Back_Color) 300 301 /** 302 * @} 303 */ 304 305 /** @defgroup LTDC_Position 306 * @{ 307 */ 308 309 #define LTDC_POS_CY LTDC_CPSR_CYPOS 310 #define LTDC_POS_CX LTDC_CPSR_CXPOS 311 312 #define IS_LTDC_GET_POS(POS) (((POS) <= LTDC_POS_CY)) 313 314 315 /** 316 * @} 317 */ 318 319 /** @defgroup LTDC_LIPosition 320 * @{ 321 */ 322 323 #define IS_LTDC_LIPOS(LIPOS) ((LIPOS) <= 0x7FF) 324 325 /** 326 * @} 327 */ 328 329 /** @defgroup LTDC_CurrentStatus 330 * @{ 331 */ 332 333 #define LTDC_CD_VDES LTDC_CDSR_VDES 334 #define LTDC_CD_HDES LTDC_CDSR_HDES 335 #define LTDC_CD_VSYNC LTDC_CDSR_VSYNCS 336 #define LTDC_CD_HSYNC LTDC_CDSR_HSYNCS 337 338 339 #define IS_LTDC_GET_CD(CD) (((CD) == LTDC_CD_VDES) || ((CD) == LTDC_CD_HDES) || \ 340 ((CD) == LTDC_CD_VSYNC) || ((CD) == LTDC_CD_HSYNC)) 341 342 343 /** 344 * @} 345 */ 346 347 /** @defgroup LTDC_Interrupts 348 * @{ 349 */ 350 351 #define LTDC_IT_LI LTDC_IER_LIE 352 #define LTDC_IT_FU LTDC_IER_FUIE 353 #define LTDC_IT_TERR LTDC_IER_TERRIE 354 #define LTDC_IT_RR LTDC_IER_RRIE 355 356 #define IS_LTDC_IT(IT) ((((IT) & (uint32_t)0xFFFFFFF0) == 0x00) && ((IT) != 0x00)) 357 358 /** 359 * @} 360 */ 361 362 /** @defgroup LTDC_Flag 363 * @{ 364 */ 365 366 #define LTDC_FLAG_LI LTDC_ISR_LIF 367 #define LTDC_FLAG_FU LTDC_ISR_FUIF 368 #define LTDC_FLAG_TERR LTDC_ISR_TERRIF 369 #define LTDC_FLAG_RR LTDC_ISR_RRIF 370 371 372 #define IS_LTDC_FLAG(FLAG) (((FLAG) == LTDC_FLAG_LI) || ((FLAG) == LTDC_FLAG_FU) || \ 373 ((FLAG) == LTDC_FLAG_TERR) || ((FLAG) == LTDC_FLAG_RR)) 374 375 /** 376 * @} 377 */ 378 379 /** @defgroup LTDC_Pixelformat 380 * @{ 381 */ 382 #define LTDC_Pixelformat_ARGB8888 ((uint32_t)0x00000000) 383 #define LTDC_Pixelformat_RGB888 ((uint32_t)0x00000001) 384 #define LTDC_Pixelformat_RGB565 ((uint32_t)0x00000002) 385 #define LTDC_Pixelformat_ARGB1555 ((uint32_t)0x00000003) 386 #define LTDC_Pixelformat_ARGB4444 ((uint32_t)0x00000004) 387 #define LTDC_Pixelformat_L8 ((uint32_t)0x00000005) 388 #define LTDC_Pixelformat_AL44 ((uint32_t)0x00000006) 389 #define LTDC_Pixelformat_AL88 ((uint32_t)0x00000007) 390 391 #define IS_LTDC_Pixelformat(Pixelformat) (((Pixelformat) == LTDC_Pixelformat_ARGB8888) || ((Pixelformat) == LTDC_Pixelformat_RGB888) || \ 392 ((Pixelformat) == LTDC_Pixelformat_RGB565) || ((Pixelformat) == LTDC_Pixelformat_ARGB1555) || \ 393 ((Pixelformat) == LTDC_Pixelformat_ARGB4444) || ((Pixelformat) == LTDC_Pixelformat_L8) || \ 394 ((Pixelformat) == LTDC_Pixelformat_AL44) || ((Pixelformat) == LTDC_Pixelformat_AL88)) 395 396 /** 397 * @} 398 */ 399 400 /** @defgroup LTDC_BlendingFactor1 401 * @{ 402 */ 403 404 #define LTDC_BlendingFactor1_CA ((uint32_t)0x00000400) 405 #define LTDC_BlendingFactor1_PAxCA ((uint32_t)0x00000600) 406 407 #define IS_LTDC_BlendingFactor1(BlendingFactor1) (((BlendingFactor1) == LTDC_BlendingFactor1_CA) || ((BlendingFactor1) == LTDC_BlendingFactor1_PAxCA)) 408 409 /** 410 * @} 411 */ 412 413 /** @defgroup LTDC_BlendingFactor2 414 * @{ 415 */ 416 417 #define LTDC_BlendingFactor2_CA ((uint32_t)0x00000005) 418 #define LTDC_BlendingFactor2_PAxCA ((uint32_t)0x00000007) 419 420 #define IS_LTDC_BlendingFactor2(BlendingFactor2) (((BlendingFactor2) == LTDC_BlendingFactor2_CA) || ((BlendingFactor2) == LTDC_BlendingFactor2_PAxCA)) 421 422 423 /** 424 * @} 425 */ 426 427 428 /** @defgroup LTDC_LAYER_Config 429 * @{ 430 */ 431 432 #define LTDC_STOPPosition ((uint32_t)0x0000FFFF) 433 #define LTDC_STARTPosition ((uint32_t)0x00000FFF) 434 435 #define LTDC_DefaultColorConfig ((uint32_t)0x000000FF) 436 #define LTDC_ColorFrameBuffer ((uint32_t)0x00001FFF) 437 #define LTDC_LineNumber ((uint32_t)0x000007FF) 438 439 #define IS_LTDC_HCONFIGST(HCONFIGST) ((HCONFIGST) <= LTDC_STARTPosition) 440 #define IS_LTDC_HCONFIGSP(HCONFIGSP) ((HCONFIGSP) <= LTDC_STOPPosition) 441 #define IS_LTDC_VCONFIGST(VCONFIGST) ((VCONFIGST) <= LTDC_STARTPosition) 442 #define IS_LTDC_VCONFIGSP(VCONFIGSP) ((VCONFIGSP) <= LTDC_STOPPosition) 443 444 #define IS_LTDC_DEFAULTCOLOR(DEFAULTCOLOR) ((DEFAULTCOLOR) <= LTDC_DefaultColorConfig) 445 446 #define IS_LTDC_CFBP(CFBP) ((CFBP) <= LTDC_ColorFrameBuffer) 447 #define IS_LTDC_CFBLL(CFBLL) ((CFBLL) <= LTDC_ColorFrameBuffer) 448 449 #define IS_LTDC_CFBLNBR(CFBLNBR) ((CFBLNBR) <= LTDC_LineNumber) 450 451 452 453 /** 454 * @} 455 */ 456 457 /** @defgroup LTDC_colorkeying_Config 458 * @{ 459 */ 460 461 #define LTDC_colorkeyingConfig ((uint32_t)0x000000FF) 462 463 #define IS_LTDC_CKEYING(CKEYING) ((CKEYING) <= LTDC_colorkeyingConfig) 464 465 466 /** 467 * @} 468 */ 469 470 /** @defgroup LTDC_CLUT_Config 471 * @{ 472 */ 473 474 #define LTDC_CLUTWR ((uint32_t)0x000000FF) 475 476 #define IS_LTDC_CLUTWR(CLUTWR) ((CLUTWR) <= LTDC_CLUTWR) 477 478 /* Exported macro ------------------------------------------------------------*/ 479 /* Exported functions ------------------------------------------------------- */ 480 481 /* Function used to set the LTDC configuration to the default reset state *****/ 482 void LTDC_DeInit(void); 483 484 /* Initialization and Configuration functions *********************************/ 485 void LTDC_Init(LTDC_InitTypeDef* LTDC_InitStruct); 486 void LTDC_StructInit(LTDC_InitTypeDef* LTDC_InitStruct); 487 void LTDC_Cmd(FunctionalState NewState); 488 void LTDC_DitherCmd(FunctionalState NewState); 489 LTDC_RGBTypeDef LTDC_GetRGBWidth(void); 490 void LTDC_RGBStructInit(LTDC_RGBTypeDef* LTDC_RGB_InitStruct); 491 void LTDC_LIPConfig(uint32_t LTDC_LIPositionConfig); 492 void LTDC_ReloadConfig(uint32_t LTDC_Reload); 493 void LTDC_LayerInit(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_Layer_InitTypeDef* LTDC_Layer_InitStruct); 494 void LTDC_LayerStructInit(LTDC_Layer_InitTypeDef * LTDC_Layer_InitStruct); 495 void LTDC_LayerCmd(LTDC_Layer_TypeDef* LTDC_Layerx, FunctionalState NewState); 496 LTDC_PosTypeDef LTDC_GetPosStatus(void); 497 void LTDC_PosStructInit(LTDC_PosTypeDef* LTDC_Pos_InitStruct); 498 FlagStatus LTDC_GetCDStatus(uint32_t LTDC_CD); 499 void LTDC_ColorKeyingConfig(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_ColorKeying_InitTypeDef* LTDC_colorkeying_InitStruct, FunctionalState NewState); 500 void LTDC_ColorKeyingStructInit(LTDC_ColorKeying_InitTypeDef* LTDC_colorkeying_InitStruct); 501 void LTDC_CLUTCmd(LTDC_Layer_TypeDef* LTDC_Layerx, FunctionalState NewState); 502 void LTDC_CLUTInit(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_CLUT_InitTypeDef* LTDC_CLUT_InitStruct); 503 void LTDC_CLUTStructInit(LTDC_CLUT_InitTypeDef* LTDC_CLUT_InitStruct); 504 void LTDC_LayerPosition(LTDC_Layer_TypeDef* LTDC_Layerx, uint16_t OffsetX, uint16_t OffsetY); 505 void LTDC_LayerAlpha(LTDC_Layer_TypeDef* LTDC_Layerx, uint8_t ConstantAlpha); 506 void LTDC_LayerAddress(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t Address); 507 void LTDC_LayerSize(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t Width, uint32_t Height); 508 void LTDC_LayerPixelFormat(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t PixelFormat); 509 510 /* Interrupts and flags management functions **********************************/ 511 void LTDC_ITConfig(uint32_t LTDC_IT, FunctionalState NewState); 512 FlagStatus LTDC_GetFlagStatus(uint32_t LTDC_FLAG); 513 void LTDC_ClearFlag(uint32_t LTDC_FLAG); 514 ITStatus LTDC_GetITStatus(uint32_t LTDC_IT); 515 void LTDC_ClearITPendingBit(uint32_t LTDC_IT); 516 517 #ifdef __cplusplus 518 } 519 #endif 520 521 #endif /* __STM32F4xx_LTDC_H */ 522 523 /** 524 * @} 525 */ 526 527 /** 528 * @} 529 */ 530 531 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 532