lcd.h Go to the documentation of this file.
1 //***************************************************************************** 2 // 3 // lcd.h - Defines and Macros for the LCD Controller module. 4 // 5 // Copyright (c) 2012-2017 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above copyright 16 // notice, this list of conditions and the following disclaimer in the 17 // documentation and/or other materials provided with the 18 // distribution. 19 // 20 // Neither the name of Texas Instruments Incorporated nor the names of 21 // its contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 // 36 //***************************************************************************** 37 38 #ifndef __DRIVERLIB_LCD_H__ 39 #define __DRIVERLIB_LCD_H__ 40 41 #include <stdint.h> 42 #include <stdbool.h> 43 44 //***************************************************************************** 45 // 48 // 49 //***************************************************************************** 50 51 //***************************************************************************** 52 // 53 // If building with a C++ compiler, make all of the definitions in this header 54 // have a C binding. 55 // 56 //***************************************************************************** 57 #ifdef __cplusplus 58 extern "C" 59 {
60 #endif 61 62 //***************************************************************************** 63 // 67 // 68 //***************************************************************************** 69 #define PAL_FROM_RGB(ui32RGBColor) (((ui32RGBColor & 0xF0) >> 4) | \ 70 ((ui32RGBColor & 0xF000) >> 8) | \ 71 ((ui32RGBColor & 0xF00000) >> 12)) 72 73 //***************************************************************************** 74 // 83 // 84 //***************************************************************************** 85 #define CYCLES_FROM_TIME_US(ui32ClockFreq, ui32Time_uS) \ 86 (((ui32Time_uS) == 0) ? 0 : \ 87 (((ui32ClockFreq) / 1000000) * ((((ui32Time_uS) * 1000) - 1) / 1000)) + 1) 88 89 //***************************************************************************** 90 // 99 // 100 //***************************************************************************** 101 #define CYCLES_FROM_TIME_NS(ui32ClockFreq, ui32Time_nS) \ 102 (((ui32Time_nS) == 0) ? 0 : \ 103 ((((((ui32ClockFreq) / 1000000) * ((ui32Time_nS) - 1)) / 1000)) + 1)) 104 105 //***************************************************************************** 106 // 109 // 110 //***************************************************************************** 111 typedef struct 112 {
113 // 118 // 119 uint8_t ui8WSSetup;
120 121 // 125 // 126 uint8_t ui8WSDuration;
127 128 // 133 // 134 uint8_t ui8WSHold;
135 136 // 141 // 142 uint8_t ui8RSSetup;
143 144 // 148 // 149 uint8_t ui8RSDuration;
150 151 // 156 // 157 uint8_t ui8RSHold;
158 159 // 164 // 165 uint8_t ui8DelayCycles;
166 }
167 tLCDIDDTiming;
168 169 // 170 // Values which can be ORed together within the ui32Flags field of the 171 // tLCDRasterTiming structure. 172 // 173 #define RASTER_TIMING_SYNCS_OPPOSITE_PIXCLK \ 174 0x00000000 175 #define RASTER_TIMING_SYNCS_ON_RISING_PIXCLK \ 176 0x02000000 177 #define RASTER_TIMING_SYNCS_ON_FALLING_PIXCLK \ 178 0x03000000 179 #define RASTER_TIMING_ACTIVE_HIGH_OE \ 180 0x00000000 181 #define RASTER_TIMING_ACTIVE_LOW_OE \ 182 0x00800000 183 #define RASTER_TIMING_ACTIVE_HIGH_PIXCLK \ 184 0x00000000 185 #define RASTER_TIMING_ACTIVE_LOW_PIXCLK \ 186 0x00400000 187 #define RASTER_TIMING_ACTIVE_HIGH_HSYNC \ 188 0x00000000 189 #define RASTER_TIMING_ACTIVE_LOW_HSYNC \ 190 0x00200000 191 #define RASTER_TIMING_ACTIVE_HIGH_VSYNC \ 192 0x00000000 193 #define RASTER_TIMING_ACTIVE_LOW_VSYNC \ 194 0x00100000 195 196 // 199 // 200 typedef struct 201 {
202 // 206 // 207 uint32_t ui32Flags;
208 209 // 212 // 213 uint16_t ui16PanelWidth;
214 215 // 218 // 219 uint16_t ui16PanelHeight;
220 221 // 224 // 225 uint16_t ui16HFrontPorch;
226 227 // 230 // 231 uint16_t ui16HBackPorch;
232 233 // 236 // 237 uint16_t ui16HSyncWidth;
238 239 // 242 // 243 uint8_t ui8VFrontPorch;
244 245 // 249 // 250 uint8_t ui8VBackPorch;
251 252 // 262 // 263 uint8_t ui8VSyncWidth;
264 265 // 270 // 271 uint8_t ui8ACBiasLineCount;
272 }
273 tLCDRasterTiming;
274 275 //***************************************************************************** 276 // 277 // Possible values for the ui8Mode parameter to LCDModeSet(). The label 278 // LCD_MODE_AUTO_UFLOW_RESTART may be ORed with either of the other two. 279 // 280 //***************************************************************************** 281 #define LCD_MODE_LIDD ((uint8_t)0x00) 282 #define LCD_MODE_RASTER ((uint8_t)0x01) 283 #define LCD_MODE_AUTO_UFLOW_RESTART \ 284 ((uint8_t)0x02) 285 286 //***************************************************************************** 287 // 288 // Values used to construct the ui32Config parameter to LCDIDDConfigSet(). 289 // 290 //***************************************************************************** 291 #define LIDD_CONFIG_SYNC_MPU68 0x00000000 292 #define LIDD_CONFIG_ASYNC_MPU68 0x00000001 293 #define LIDD_CONFIG_SYNC_MPU80 0x00000002 294 #define LIDD_CONFIG_ASYNC_MPU80 0x00000003 295 #define LIDD_CONFIG_ASYNC_HITACHI \ 296 0x00000004 297 #define LIDD_CONFIG_INVERT_ALE 0x00000008 298 #define LIDD_CONFIG_INVERT_RS_EN \ 299 0x00000010 300 #define LIDD_CONFIG_INVERT_WS_DIR \ 301 0x00000020 302 #define LIDD_CONFIG_INVERT_CS0 0x00000040 303 #define LIDD_CONFIG_INVERT_CS1 0x00000080 304 305 //***************************************************************************** 306 // 307 // Values used to construct the ui32Config parameter to 308 // LCDRasterConfigSet(). Valid parameters contain one of the RASTER_FMT_xxx 309 // labels optionally ORed with the other flags. Only one of 310 // RASTER_LOAD_DATA_ONLY and RASTER_LOAD_PALETTE_ONLY may be specified (if 311 // neither is specified, the controller will load both palette and data when 312 // scanning out the frame buffer). 313 // 314 //***************************************************************************** 315 #define RASTER_FMT_ACTIVE_24BPP_PACKED \ 316 0x02000080 317 #define RASTER_FMT_ACTIVE_24BPP_UNPACKED \ 318 0x06000080 319 #define RASTER_FMT_ACTIVE_PALETTIZED_12BIT \ 320 0x00000080 321 #define RASTER_FMT_ACTIVE_PALETTIZED_16BIT \ 322 0x00800080 323 #define RASTER_FMT_PASSIVE_MONO_4PIX \ 324 0x00000002 325 #define RASTER_FMT_PASSIVE_MONO_8PIX \ 326 0x00000202 327 #define RASTER_FMT_PASSIVE_PALETTIZED \ 328 0x00000000 329 #define RASTER_FMT_PASSIVE_COLOR_12BIT \ 330 0x00000000 331 #define RASTER_FMT_PASSIVE_COLOR_16BIT \ 332 0x01000000 333 #define RASTER_ACTVID_DURING_BLANK \ 334 0x08000000 335 #define RASTER_NIBBLE_MODE_ENABLED \ 336 0x00400000 337 #define RASTER_LOAD_DATA_ONLY 0x00200000 338 #define RASTER_LOAD_PALETTE_ONLY \ 339 0x00100000 340 #define RASTER_READ_ORDER_REVERSED \ 341 0x00000100 342 343 //***************************************************************************** 344 // 345 // Interrupt sources for the LCD controller. These may be ORed together and 346 // passed to LCDIntEnable(), LCDIntDisable() and LCDIntClear(). They are also 347 // returned by LCDIntStatus(). 348 // 349 //***************************************************************************** 350 #define LCD_INT_DMA_DONE 0x00000001 351 #define LCD_INT_RASTER_FRAME_DONE \ 352 0x00000002 353 #define LCD_INT_SYNC_LOST 0x00000004 354 #define LCD_INT_AC_BIAS_CNT 0x00000008 355 #define LCD_INT_UNDERFLOW 0x00000020 356 #define LCD_INT_PAL_LOAD 0x00000040 357 #define LCD_INT_EOF0 0x00000100 358 #define LCD_INT_EOF1 0x00000200 359 360 //***************************************************************************** 361 // 362 // Configuration values used with LCDDMAConfigSet(). 363 // 364 //***************************************************************************** 365 #define LCD_DMA_FIFORDY_8_WORDS 0x00000000 366 #define LCD_DMA_FIFORDY_16_WORDS \ 367 0x00000100 368 #define LCD_DMA_FIFORDY_32_WORDS \ 369 0x00000200 370 #define LCD_DMA_FIFORDY_64_WORDS \ 371 0x00000300 372 #define LCD_DMA_FIFORDY_128_WORDS \ 373 0x00000400 374 #define LCD_DMA_FIFORDY_256_WORDS \ 375 0x00000500 376 #define LCD_DMA_FIFORDY_512_WORDS \ 377 0x00000600 378 #define LCD_DMA_BURST_1 0x00000010 379 #define LCD_DMA_BURST_2 0x00000010 380 #define LCD_DMA_BURST_4 0x00000020 381 #define LCD_DMA_BURST_8 0x00000030 382 #define LCD_DMA_BURST_16 0x00000040 383 #define LCD_DMA_BYTE_ORDER_0123 0x00000000 384 #define LCD_DMA_BYTE_ORDER_1023 0x00000008 385 #define LCD_DMA_BYTE_ORDER_3210 0x00000002 386 #define LCD_DMA_BYTE_ORDER_2301 0x0000000A 387 #define LCD_DMA_PING_PONG 0x00000001 388 389 //***************************************************************************** 390 // 391 // Type values used with LCDRasterPaletteSet(). 392 // 393 //***************************************************************************** 394 #define LCD_PALETTE_TYPE_1BPP 0x00000000 395 #define LCD_PALETTE_TYPE_2BPP 0x00001000 396 #define LCD_PALETTE_TYPE_4BPP 0x00002000 397 #define LCD_PALETTE_TYPE_8BPP 0x00003000 398 #define LCD_PALETTE_TYPE_DIRECT 0x00004000 399 #define LCD_PALETTE_SRC_24BIT 0x80000000 400 401 //***************************************************************************** 402 // 403 // Flags used in the ui32Clocks parameter to LCDClockReset(). 404 // 405 //***************************************************************************** 406 #define LCD_CLOCK_MAIN 0x00000008 407 #define LCD_CLOCK_DMA 0x00000004 408 #define LCD_CLOCK_LIDD 0x00000002 409 #define LCD_CLOCK_CORE 0x00000001 410 411 //***************************************************************************** 412 // 413 // Flags used in with LCDSubPanelConfigSet(). 414 // 415 //***************************************************************************** 416 #define LCD_SUBPANEL_AT_TOP 0x20000000 417 #define LCD_SUBPANEL_AT_BOTTOM 0x00000000 418 419 //***************************************************************************** 420 // 421 // Close the Doxygen group. 423 // 424 //***************************************************************************** 425 426 //***************************************************************************** 427 // 428 // Function Prototypes. 429 // 430 //***************************************************************************** 431 extern uint32_t LCDModeSet(uint32_t ui32Base, uint8_t ui8Mode,
432 uint32_t ui32PixClk, uint32_t ui32SysClk);
433 extern void LCDClockReset(uint32_t ui32Base, uint32_t ui32Clocks);
434 extern void LCDIDDConfigSet(uint32_t ui32Base, uint32_t ui32Config);
435 extern void LCDIDDTimingSet(uint32_t ui32Base, uint32_t ui32CS,
436 const tLCDIDDTiming *pTiming);
437 extern void LCDIDDDMADisable(uint32_t ui32Base);
438 extern void LCDIDDCommandWrite(uint32_t ui32Base, uint32_t ui32CS,
439 uint16_t ui16Cmd);
440 extern void LCDIDDDataWrite(uint32_t ui32Base, uint32_t ui32CS,
441 uint16_t ui16Data);
442 extern void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS,
443 uint16_t ui16Addr, uint16_t ui16Data);
444 extern uint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS);
445 extern uint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS);
446 extern uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS,
447 uint16_t ui16Addr);
448 extern void LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS,
449 const uint32_t *pui32Data, uint32_t ui32Count);
450 extern void LCDRasterConfigSet(uint32_t ui32Base, uint32_t ui32Config,
451 uint8_t ui8PalLoadDelay);
452 extern void LCDRasterTimingSet(uint32_t ui32Base,
453 const tLCDRasterTiming *pTiming);
454 extern void LCDRasterACBiasIntCountSet(uint32_t ui32Base, uint8_t ui8Count);
455 extern void LCDRasterEnable(uint32_t ui32Base);
456 extern bool LCDRasterEnabled(uint32_t ui32Base);
457 extern void LCDRasterDisable(uint32_t ui32Base);
458 extern void LCDRasterSubPanelConfigSet(uint32_t ui32Base, uint32_t ui32Flags,
459 uint32_t ui32BottomLines,
460 uint32_t ui32DefaultPixel);
461 extern void LCDRasterSubPanelEnable(uint32_t ui32Base);
462 extern void LCDRasterSubPanelDisable(uint32_t ui32Base);
463 extern void LCDDMAConfigSet(uint32_t ui32Base, uint32_t ui32Config);
464 extern void LCDRasterPaletteSet(uint32_t ui32Base, uint32_t ui32Type,
465 uint32_t *pui32PalAddr,
466 const uint32_t *pui32SrcColors,
467 uint32_t ui32Start,
468 uint32_t ui32Count);
469 extern void LCDRasterFrameBufferSet(uint32_t ui32Base, uint8_t ui8Buffer,
470 uint32_t *pui32Addr,
471 uint32_t ui32NumBytes);
472 extern void LCDIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
473 extern void LCDIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
474 extern uint32_t LCDIntStatus(uint32_t ui32Base,
bool bMasked);
475 extern void LCDIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
476 extern void LCDIntRegister(uint32_t ui32Base,
void (*pfnHandler)(
void));
477 extern void LCDIntUnregister(uint32_t ui32Base);
478 479 //***************************************************************************** 480 // 481 // Mark the end of the C bindings section for C++ compilers. 482 // 483 //***************************************************************************** 484 #ifdef __cplusplus 485 }
486 #endif 487 488 #endif // __DRIVERLIB_LCD_H__LCDRasterSubPanelDisablevoid LCDRasterSubPanelDisable(uint32_t ui32Base)Definition: lcd.c:1216 LCDIDDDataWritevoid LCDIDDDataWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Data)Definition: lcd.c:443 LCDIDDDMADisablevoid LCDIDDDMADisable(uint32_t ui32Base)Definition: lcd.c:361 tLCDIDDTiming::ui8RSSetupuint8_t ui8RSSetupDefinition: lcd.h:142 tLCDIDDTiming::ui8WSSetupuint8_t ui8WSSetupDefinition: lcd.h:119 tLCDIDDTiming::ui8RSHolduint8_t ui8RSHoldDefinition: lcd.h:157 tLCDRasterTiming::ui8VBackPorchuint8_t ui8VBackPorchDefinition: lcd.h:250 tLCDIDDTiming::ui8WSDurationuint8_t ui8WSDurationDefinition: lcd.h:126 LCDRasterPaletteSetvoid LCDRasterPaletteSet(uint32_t ui32Base, uint32_t ui32Type, uint32_t *pui32PalAddr, const uint32_t *pui32SrcColors, uint32_t ui32Start, uint32_t ui32Count)Definition: lcd.c:1364 LCDModeSetuint32_t LCDModeSet(uint32_t ui32Base, uint8_t ui8Mode, uint32_t ui32PixClk, uint32_t ui32SysClk)Definition: lcd.c:107 LCDIntEnablevoid LCDIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)Definition: lcd.c:1541 LCDIntDisablevoid LCDIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)Definition: lcd.c:1591 LCDRasterFrameBufferSetvoid LCDRasterFrameBufferSet(uint32_t ui32Base, uint8_t ui8Buffer, uint32_t *pui32Addr, uint32_t ui32NumBytes)Definition: lcd.c:1473 LCDRasterSubPanelEnablevoid LCDRasterSubPanelEnable(uint32_t ui32Base)Definition: lcd.c:1187 tLCDIDDTiming::ui8WSHolduint8_t ui8WSHoldDefinition: lcd.h:134 LCDIDDDMAWritevoid LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS, const uint32_t *pui32Data, uint32_t ui32Count)Definition: lcd.c:718 LCDIDDTimingSetvoid LCDIDDTimingSet(uint32_t ui32Base, uint32_t ui32CS, const tLCDIDDTiming *pTiming)Definition: lcd.c:298 LCDIDDIndexedReaduint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)Definition: lcd.c:652 LCDRasterSubPanelConfigSetvoid LCDRasterSubPanelConfigSet(uint32_t ui32Base, uint32_t ui32Flags, uint32_t ui32BottomLines, uint32_t ui32DefaultPixel)Definition: lcd.c:1131 tLCDRasterTiming::ui8ACBiasLineCountuint8_t ui8ACBiasLineCountDefinition: lcd.h:271 LCDIDDIndexedWritevoid LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr, uint16_t ui16Data)Definition: lcd.c:497 tLCDRasterTiming::ui8VFrontPorchuint8_t ui8VFrontPorchDefinition: lcd.h:243 LCDIntRegistervoid LCDIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))Definition: lcd.c:1741 tLCDIDDTiming::ui8DelayCyclesuint8_t ui8DelayCyclesDefinition: lcd.h:165 LCDIDDConfigSetvoid LCDIDDConfigSet(uint32_t ui32Base, uint32_t ui32Config)Definition: lcd.c:255 tLCDRasterTiming::ui16HFrontPorchuint16_t ui16HFrontPorchDefinition: lcd.h:225 tLCDIDDTimingDefinition: lcd.h:111 tLCDRasterTiming::ui32Flagsuint32_t ui32FlagsDefinition: lcd.h:207 tLCDRasterTiming::ui16PanelWidthuint16_t ui16PanelWidthDefinition: lcd.h:213 LCDIDDStatusReaduint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS)Definition: lcd.c:555 tLCDRasterTiming::ui8VSyncWidthuint8_t ui8VSyncWidthDefinition: lcd.h:263 LCDRasterDisablevoid LCDRasterDisable(uint32_t ui32Base)Definition: lcd.c:1076 LCDIntUnregistervoid LCDIntUnregister(uint32_t ui32Base)Definition: lcd.c:1779 LCDIntClearvoid LCDIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)Definition: lcd.c:1706 tLCDRasterTiming::ui16HSyncWidthuint16_t ui16HSyncWidthDefinition: lcd.h:237 tLCDRasterTiming::ui16PanelHeightuint16_t ui16PanelHeightDefinition: lcd.h:219 LCDClockResetvoid LCDClockReset(uint32_t ui32Base, uint32_t ui32Clocks)Definition: lcd.c:178 LCDIntStatusuint32_t LCDIntStatus(uint32_t ui32Base, bool bMasked)Definition: lcd.c:1640 LCDRasterTimingSetvoid LCDRasterTimingSet(uint32_t ui32Base, const tLCDRasterTiming *pTiming)Definition: lcd.c:891 LCDDMAConfigSetvoid LCDDMAConfigSet(uint32_t ui32Base, uint32_t ui32Config)Definition: lcd.c:1290 LCDRasterEnabledbool LCDRasterEnabled(uint32_t ui32Base)Definition: lcd.c:1044 LCDIDDDataReaduint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS)Definition: lcd.c:600 LCDRasterConfigSetvoid LCDRasterConfigSet(uint32_t ui32Base, uint32_t ui32Config, uint8_t ui8PalLoadDelay)Definition: lcd.c:843 LCDRasterACBiasIntCountSetvoid LCDRasterACBiasIntCountSet(uint32_t ui32Base, uint8_t ui8Count)Definition: lcd.c:971 LCDIDDCommandWritevoid LCDIDDCommandWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Cmd)Definition: lcd.c:398 LCDRasterEnablevoid LCDRasterEnable(uint32_t ui32Base)Definition: lcd.c:1011 tLCDIDDTiming::ui8RSDurationuint8_t ui8RSDurationDefinition: lcd.h:149 tLCDRasterTimingDefinition: lcd.h:200 tLCDRasterTiming::ui16HBackPorchuint16_t ui16HBackPorchDefinition: lcd.h:231 Copyright 2018, Texas Instruments Incorporated