LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lcd_18xx_43xx.c
Go to the documentation of this file.
1 /*
2  * @brief LPC18xx/43xx LCD chip driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #include "chip.h"
33 
34 /*****************************************************************************
35  * Private types/enumerations/variables
36  ****************************************************************************/
37 
39 
40 /*****************************************************************************
41  * Public types/enumerations/variables
42  ****************************************************************************/
43 
44 /*****************************************************************************
45  * Private functions
46  ****************************************************************************/
47 
48 /*****************************************************************************
49  * Public functions
50  ****************************************************************************/
51 
52 /* Initialize the LCD controller */
53 void Chip_LCD_Init(LPC_LCD_T *pLCD, LCD_Config_T *LCD_ConfigStruct)
54 {
55  Chip_Clock_EnableOpts(CLK_MX_LCD, true, true, 1);
56  IP_LCD_Init(pLCD, LCD_ConfigStruct);
57 }
58 
59 /* Shutdown the LCD controller */
61 {
63 }
64 
65 /* Configure Cursor */
67 {
68  LCD_Cursor_Size = cursor_size;
69  IP_LCD_Cursor_Config(pLCD, cursor_size, sync);
70 }
71 
72 /* Write Cursor Image into Internal Cursor Image Buffer */
73 void Chip_LCD_Cursor_WriteImage(LPC_LCD_T *pLCD, uint8_t cursor_num, void *Image)
74 {
75  int i, j;
76  uint32_t *fifoptr, *crsr_ptr = (uint32_t *) Image;
77 
78  /* Check if Cursor Size was configured as 32x32 or 64x64*/
80  i = cursor_num * 64;
81  j = i + 64;
82  }
83  else {
84  i = 0;
85  j = 256;
86  }
87  fifoptr = IP_LCD_Cursor_GetImageBufferAddress(pLCD, 0);
88 
89  /* Copy Cursor Image content to FIFO */
90  for (; i < j; i++) {
91 
92  *fifoptr = *crsr_ptr;
93  crsr_ptr++;
94  fifoptr++;
95  }
96 }
97 
98 /* Load LCD Palette */
99 void Chip_LCD_LoadPalette(LPC_LCD_T *pLCD, void *palette)
100 {
101  LCD_PALETTE_ENTRY_T pal_entry, *ptr_pal_entry;
102  uint8_t i, *pal_ptr;
103  /* This function supports loading of the color palette from
104  the C file generated by the bmp2c utility. It expects the
105  palette to be passed as an array of 32-bit BGR entries having
106  the following format:
107  2:0 - Not used
108  7:3 - Blue
109  10:8 - Not used
110  15:11 - Green
111  18:16 - Not used
112  23:19 - Red
113  31:24 - Not used
114  arg = pointer to input palette table address */
115  ptr_pal_entry = &pal_entry;
116  pal_ptr = (uint8_t *) palette;
117 
118  /* 256 entry in the palette table */
119  for (i = 0; i < 256 / 2; i++) {
120  pal_entry.Bl = (*pal_ptr++) >> 3; /* blue first */
121  pal_entry.Gl = (*pal_ptr++) >> 3; /* get green */
122  pal_entry.Rl = (*pal_ptr++) >> 3; /* get red */
123  pal_ptr++; /* skip over the unused byte */
124  /* do the most significant halfword of the palette */
125  pal_entry.Bu = (*pal_ptr++) >> 3; /* blue first */
126  pal_entry.Gu = (*pal_ptr++) >> 3; /* get green */
127  pal_entry.Ru = (*pal_ptr++) >> 3; /* get red */
128  pal_ptr++; /* skip over the unused byte */
129 
130  IP_LCD_Color_LoadPalette(pLCD, (uint32_t *) &ptr_pal_entry, i);
131  }
132 }