EE445M RTOS
Taken at the University of Texas Spring 2015
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-2014 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 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_LCD_H__
41 #define __DRIVERLIB_LCD_H__
42 
43 //*****************************************************************************
44 //
47 //
48 //*****************************************************************************
49 
50 //*****************************************************************************
51 //
52 // If building with a C++ compiler, make all of the definitions in this header
53 // have a C binding.
54 //
55 //*****************************************************************************
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
61 //*****************************************************************************
62 //
66 //
67 //*****************************************************************************
68 #define PAL_FROM_RGB(ui32RGBColor) (((ui32RGBColor & 0xF0) >> 4) | \
69  ((ui32RGBColor & 0xF000) >> 8) | \
70  ((ui32RGBColor & 0xF00000) >> 12))
71 
72 //*****************************************************************************
73 //
82 //
83 //*****************************************************************************
84 #define CYCLES_FROM_TIME_US(ui32ClockFreq, ui32Time_uS) \
85  (((ui32Time_uS) == 0) ? 0 : \
86  (((ui32ClockFreq) / 1000000) * ((((ui32Time_uS) * 1000) - 1) / 1000)) + 1)
87 
88 //*****************************************************************************
89 //
98 //
99 //*****************************************************************************
100 #define CYCLES_FROM_TIME_NS(ui32ClockFreq, ui32Time_nS) \
101  (((ui32Time_nS) == 0) ? 0 : \
102  ((((((ui32ClockFreq) / 1000000) * ((ui32Time_nS) - 1)) / 1000)) + 1))
103 
104 //*****************************************************************************
105 //
108 //
109 //*****************************************************************************
110 typedef struct
111 {
112  //
117  //
118  uint8_t ui8WSSetup;
119 
120  //
124  //
125  uint8_t ui8WSDuration;
126 
127  //
132  //
133  uint8_t ui8WSHold;
134 
135  //
140  //
141  uint8_t ui8RSSetup;
142 
143  //
147  //
148  uint8_t ui8RSDuration;
149 
150  //
155  //
156  uint8_t ui8RSHold;
157 
158  //
163  //
164  uint8_t ui8DelayCycles;
165 }
167 
168 //
169 // Values which can be ORed together within the ui32Flags field of the
170 // tLCDRasterTiming structure.
171 //
172 #define RASTER_TIMING_SYNCS_OPPOSITE_PIXCLK \
173  0x00000000
174 #define RASTER_TIMING_SYNCS_ON_RISING_PIXCLK \
175  0x02000000
176 #define RASTER_TIMING_SYNCS_ON_FALLING_PIXCLK \
177  0x03000000
178 #define RASTER_TIMING_ACTIVE_HIGH_OE \
179  0x00000000
180 #define RASTER_TIMING_ACTIVE_LOW_OE \
181  0x00800000
182 #define RASTER_TIMING_ACTIVE_HIGH_PIXCLK \
183  0x00000000
184 #define RASTER_TIMING_ACTIVE_LOW_PIXCLK \
185  0x00400000
186 #define RASTER_TIMING_ACTIVE_HIGH_HSYNC \
187  0x00000000
188 #define RASTER_TIMING_ACTIVE_LOW_HSYNC \
189  0x00200000
190 #define RASTER_TIMING_ACTIVE_HIGH_VSYNC \
191  0x00000000
192 #define RASTER_TIMING_ACTIVE_LOW_VSYNC \
193  0x00100000
194 
195 //
198 //
199 typedef struct
200 {
201  //
205  //
206  uint32_t ui32Flags;
207 
208  //
211  //
212  uint16_t ui16PanelWidth;
213 
214  //
217  //
218  uint16_t ui16PanelHeight;
219 
220  //
223  //
224  uint16_t ui16HFrontPorch;
225 
226  //
229  //
230  uint16_t ui16HBackPorch;
231 
232  //
235  //
236  uint16_t ui16HSyncWidth;
237 
238  //
241  //
242  uint8_t ui8VFrontPorch;
243 
244  //
248  //
249  uint8_t ui8VBackPorch;
250 
251  //
261  //
262  uint8_t ui8VSyncWidth;
263 
264  //
269  //
271 }
273 
274 //*****************************************************************************
275 //
276 // Possible values for the ui8Mode parameter to LCDModeSet(). The label
277 // LCD_MODE_AUTO_UFLOW_RESTART may be ORed with either of the other two.
278 //
279 //*****************************************************************************
280 #define LCD_MODE_LIDD ((uint8_t)0x00)
281 #define LCD_MODE_RASTER ((uint8_t)0x01)
282 #define LCD_MODE_AUTO_UFLOW_RESTART \
283  ((uint8_t)0x02)
284 
285 //*****************************************************************************
286 //
287 // Values used to construct the ui32Config parameter to LCDIDDConfigSet().
288 //
289 //*****************************************************************************
290 #define LIDD_CONFIG_SYNC_MPU68 0x00000000
291 #define LIDD_CONFIG_ASYNC_MPU68 0x00000001
292 #define LIDD_CONFIG_SYNC_MPU80 0x00000002
293 #define LIDD_CONFIG_ASYNC_MPU80 0x00000003
294 #define LIDD_CONFIG_ASYNC_HITACHI \
295  0x00000004
296 #define LIDD_CONFIG_INVERT_ALE 0x00000008
297 #define LIDD_CONFIG_INVERT_RS_EN \
298  0x00000010
299 #define LIDD_CONFIG_INVERT_WS_DIR \
300  0x00000020
301 #define LIDD_CONFIG_INVERT_CS0 0x00000040
302 #define LIDD_CONFIG_INVERT_CS1 0x00000080
303 
304 //*****************************************************************************
305 //
306 // Values used to construct the ui32Config parameter to
307 // LCDRasterConfigSet(). Valid parameters contain one of the RASTER_FMT_xxx
308 // labels optionally ORed with the other flags. Only one of
309 // RASTER_LOAD_DATA_ONLY and RASTER_LOAD_PALETTE_ONLY may be specified (if
310 // neither is specified, the controller will load both palette and data when
311 // scanning out the frame buffer).
312 //
313 //*****************************************************************************
314 #define RASTER_FMT_ACTIVE_24BPP_PACKED \
315  0x02000080
316 #define RASTER_FMT_ACTIVE_24BPP_UNPACKED \
317  0x06000080
318 #define RASTER_FMT_ACTIVE_PALETTIZED_12BIT \
319  0x00000080
320 #define RASTER_FMT_ACTIVE_PALETTIZED_16BIT \
321  0x00800080
322 #define RASTER_FMT_PASSIVE_MONO_4PIX \
323  0x00000002
324 #define RASTER_FMT_PASSIVE_MONO_8PIX \
325  0x00000202
326 #define RASTER_FMT_PASSIVE_PALETTIZED \
327  0x00000000
328 #define RASTER_FMT_PASSIVE_COLOR_12BIT \
329  0x00000000
330 #define RASTER_FMT_PASSIVE_COLOR_16BIT \
331  0x01000000
332 #define RASTER_ACTVID_DURING_BLANK \
333  0x08000000
334 #define RASTER_NIBBLE_MODE_ENABLED \
335  0x00400000
336 #define RASTER_LOAD_DATA_ONLY 0x00200000
337 #define RASTER_LOAD_PALETTE_ONLY \
338  0x00100000
339 #define RASTER_READ_ORDER_REVERSED \
340  0x00000100
341 
342 //*****************************************************************************
343 //
344 // Interrupt sources for the LCD controller. These may be ORed together and
345 // passed to LCDIntEnable(), LCDIntDisable() and LCDIntClear(). They are also
346 // returned by LCDIntStatus().
347 //
348 //*****************************************************************************
349 #define LCD_INT_DMA_DONE 0x00000001
350 #define LCD_INT_RASTER_FRAME_DONE \
351  0x00000002
352 #define LCD_INT_SYNC_LOST 0x00000004
353 #define LCD_INT_AC_BIAS_CNT 0x00000008
354 #define LCD_INT_UNDERFLOW 0x00000020
355 #define LCD_INT_PAL_LOAD 0x00000040
356 #define LCD_INT_EOF0 0x00000100
357 #define LCD_INT_EOF1 0x00000200
358 
359 //*****************************************************************************
360 //
361 // Configuration values used with LCDDMAConfigSet().
362 //
363 //*****************************************************************************
364 #define LCD_DMA_FIFORDY_8_WORDS 0x00000000
365 #define LCD_DMA_FIFORDY_16_WORDS \
366  0x00000100
367 #define LCD_DMA_FIFORDY_32_WORDS \
368  0x00000200
369 #define LCD_DMA_FIFORDY_64_WORDS \
370  0x00000300
371 #define LCD_DMA_FIFORDY_128_WORDS \
372  0x00000400
373 #define LCD_DMA_FIFORDY_256_WORDS \
374  0x00000500
375 #define LCD_DMA_FIFORDY_512_WORDS \
376  0x00000600
377 #define LCD_DMA_BURST_1 0x00000010
378 #define LCD_DMA_BURST_2 0x00000010
379 #define LCD_DMA_BURST_4 0x00000020
380 #define LCD_DMA_BURST_8 0x00000030
381 #define LCD_DMA_BURST_16 0x00000040
382 #define LCD_DMA_BYTE_ORDER_0123 0x00000000
383 #define LCD_DMA_BYTE_ORDER_1023 0x00000008
384 #define LCD_DMA_BYTE_ORDER_3210 0x00000002
385 #define LCD_DMA_BYTE_ORDER_2301 0x0000000A
386 #define LCD_DMA_PING_PONG 0x00000001
387 
388 //*****************************************************************************
389 //
390 // Type values used with LCDRasterPaletteSet().
391 //
392 //*****************************************************************************
393 #define LCD_PALETTE_TYPE_1BPP 0x00000000
394 #define LCD_PALETTE_TYPE_2BPP 0x00001000
395 #define LCD_PALETTE_TYPE_4BPP 0x00002000
396 #define LCD_PALETTE_TYPE_8BPP 0x00003000
397 #define LCD_PALETTE_TYPE_DIRECT 0x00004000
398 #define LCD_PALETTE_SRC_24BIT 0x80000000
399 
400 //*****************************************************************************
401 //
402 // Flags used in the ui32Clocks parameter to LCDClockReset().
403 //
404 //*****************************************************************************
405 #define LCD_CLOCK_MAIN 0x00000008
406 #define LCD_CLOCK_DMA 0x00000004
407 #define LCD_CLOCK_LIDD 0x00000002
408 #define LCD_CLOCK_CORE 0x00000001
409 
410 //*****************************************************************************
411 //
412 // Flags used in with LCDSubPanelConfigSet().
413 //
414 //*****************************************************************************
415 #define LCD_SUBPANEL_AT_TOP 0x20000000
416 #define LCD_SUBPANEL_AT_BOTTOM 0x00000000
417 
418 //*****************************************************************************
419 //
420 // Close the Doxygen group.
422 //
423 //*****************************************************************************
424 
425 //*****************************************************************************
426 //
427 // Function Prototypes.
428 //
429 //*****************************************************************************
430 extern uint32_t LCDModeSet(uint32_t ui32Base, uint8_t ui8Mode,
431  uint32_t ui32PixClk, uint32_t ui32SysClk);
432 extern void LCDClockReset(uint32_t ui32Base, uint32_t ui32Clocks);
433 extern void LCDIDDConfigSet(uint32_t ui32Base, uint32_t ui32Config);
434 extern void LCDIDDTimingSet(uint32_t ui32Base, uint32_t ui32CS,
435  const tLCDIDDTiming *pTiming);
436 extern void LCDIDDDMADisable(uint32_t ui32Base);
437 extern void LCDIDDCommandWrite(uint32_t ui32Base, uint32_t ui32CS,
438  uint16_t ui16Cmd);
439 extern void LCDIDDDataWrite(uint32_t ui32Base, uint32_t ui32CS,
440  uint16_t ui16Data);
441 extern void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS,
442  uint16_t ui16Addr, uint16_t ui16Data);
443 extern uint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS);
444 extern uint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS);
445 extern uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS,
446  uint16_t ui16Addr);
447 extern void LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS,
448  const uint32_t *pui32Data, uint32_t ui32Count);
449 extern void LCDRasterConfigSet(uint32_t ui32Base, uint32_t ui32Config,
450  uint8_t ui8PalLoadDelay);
451 extern void LCDRasterTimingSet(uint32_t ui32Base,
452  const tLCDRasterTiming *pTiming);
453 extern void LCDRasterACBiasIntCountSet(uint32_t ui32Base, uint8_t ui8Count);
454 extern void LCDRasterEnable(uint32_t ui32Base);
455 extern bool LCDRasterEnabled(uint32_t ui32Base);
456 extern void LCDRasterDisable(uint32_t ui32Base);
457 extern void LCDRasterSubPanelConfigSet(uint32_t ui32Base, uint32_t ui32Flags,
458  uint32_t ui32BottomLines,
459  uint32_t ui32DefaultPixel);
460 extern void LCDRasterSubPanelEnable(uint32_t ui32Base);
461 extern void LCDRasterSubPanelDisable(uint32_t ui32Base);
462 extern void LCDDMAConfigSet(uint32_t ui32Base, uint32_t ui32Config);
463 extern void LCDRasterPaletteSet(uint32_t ui32Base, uint32_t ui32Type,
464  uint32_t *pui32PalAddr,
465  const uint32_t *pui32SrcColors,
466  uint32_t ui32Start,
467  uint32_t ui32Count);
468 extern void LCDRasterFrameBufferSet(uint32_t ui32Base, uint8_t ui8Buffer,
469  uint32_t *pui32Addr,
470  uint32_t ui32NumBytes);
471 extern void LCDIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
472 extern void LCDIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
473 extern uint32_t LCDIntStatus(uint32_t ui32Base, bool bMasked);
474 extern void LCDIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
475 extern void LCDIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
476 extern void LCDIntUnregister(uint32_t ui32Base);
477 
478 //*****************************************************************************
479 //
480 // Mark the end of the C bindings section for C++ compilers.
481 //
482 //*****************************************************************************
483 #ifdef __cplusplus
484 }
485 #endif
486 
487 #endif // __DRIVERLIB_LCD_H__
void LCDRasterSubPanelDisable(uint32_t ui32Base)
Definition: lcd.c:1219
void LCDIDDDataWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Data)
Definition: lcd.c:446
void LCDIDDDMADisable(uint32_t ui32Base)
Definition: lcd.c:364
uint8_t ui8RSSetup
Definition: lcd.h:141
uint8_t ui8WSSetup
Definition: lcd.h:118
uint8_t ui8RSHold
Definition: lcd.h:156
uint8_t ui8VBackPorch
Definition: lcd.h:249
uint8_t ui8WSDuration
Definition: lcd.h:125
void LCDRasterPaletteSet(uint32_t ui32Base, uint32_t ui32Type, uint32_t *pui32PalAddr, const uint32_t *pui32SrcColors, uint32_t ui32Start, uint32_t ui32Count)
Definition: lcd.c:1367
uint32_t LCDModeSet(uint32_t ui32Base, uint8_t ui8Mode, uint32_t ui32PixClk, uint32_t ui32SysClk)
Definition: lcd.c:110
void LCDIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: lcd.c:1544
void LCDIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: lcd.c:1594
void LCDRasterFrameBufferSet(uint32_t ui32Base, uint8_t ui8Buffer, uint32_t *pui32Addr, uint32_t ui32NumBytes)
Definition: lcd.c:1476
void LCDRasterSubPanelEnable(uint32_t ui32Base)
Definition: lcd.c:1190
uint8_t ui8WSHold
Definition: lcd.h:133
void LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS, const uint32_t *pui32Data, uint32_t ui32Count)
Definition: lcd.c:721
void LCDIDDTimingSet(uint32_t ui32Base, uint32_t ui32CS, const tLCDIDDTiming *pTiming)
Definition: lcd.c:301
uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
Definition: lcd.c:655
void LCDRasterSubPanelConfigSet(uint32_t ui32Base, uint32_t ui32Flags, uint32_t ui32BottomLines, uint32_t ui32DefaultPixel)
Definition: lcd.c:1134
uint8_t ui8ACBiasLineCount
Definition: lcd.h:270
void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr, uint16_t ui16Data)
Definition: lcd.c:500
uint8_t ui8VFrontPorch
Definition: lcd.h:242
void LCDIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: lcd.c:1744
uint8_t ui8DelayCycles
Definition: lcd.h:164
void LCDIDDConfigSet(uint32_t ui32Base, uint32_t ui32Config)
Definition: lcd.c:258
uint16_t ui16HFrontPorch
Definition: lcd.h:224
uint32_t ui32Flags
Definition: lcd.h:206
uint16_t ui16PanelWidth
Definition: lcd.h:212
uint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS)
Definition: lcd.c:558
uint8_t ui8VSyncWidth
Definition: lcd.h:262
void LCDRasterDisable(uint32_t ui32Base)
Definition: lcd.c:1079
void LCDIntUnregister(uint32_t ui32Base)
Definition: lcd.c:1782
void LCDIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: lcd.c:1709
uint16_t ui16HSyncWidth
Definition: lcd.h:236
uint16_t ui16PanelHeight
Definition: lcd.h:218
void LCDClockReset(uint32_t ui32Base, uint32_t ui32Clocks)
Definition: lcd.c:181
uint32_t LCDIntStatus(uint32_t ui32Base, bool bMasked)
Definition: lcd.c:1643
void LCDRasterTimingSet(uint32_t ui32Base, const tLCDRasterTiming *pTiming)
Definition: lcd.c:894
void LCDDMAConfigSet(uint32_t ui32Base, uint32_t ui32Config)
Definition: lcd.c:1293
bool LCDRasterEnabled(uint32_t ui32Base)
Definition: lcd.c:1047
uint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS)
Definition: lcd.c:603
void LCDRasterConfigSet(uint32_t ui32Base, uint32_t ui32Config, uint8_t ui8PalLoadDelay)
Definition: lcd.c:846
void LCDRasterACBiasIntCountSet(uint32_t ui32Base, uint8_t ui8Count)
Definition: lcd.c:974
void LCDIDDCommandWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Cmd)
Definition: lcd.c:401
void LCDRasterEnable(uint32_t ui32Base)
Definition: lcd.c:1014
uint8_t ui8RSDuration
Definition: lcd.h:148
uint16_t ui16HBackPorch
Definition: lcd.h:230