| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lcd_17xx_40xx.c
Go to the documentation of this file.
1 /*
2 * @brief LPC17xx/40xx 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 #if !defined(CHIP_LPC175X_6X)
35
36 /*****************************************************************************
37 * Private types/enumerations/variables
38 ****************************************************************************/
39
40 static IP_LCD_CURSOR_SIZE_OPT_T LCD_Cursor_Size = LCD_CURSOR_64x64;
41
42 /*****************************************************************************
43 * Public types/enumerations/variables
44 ****************************************************************************/
45
46 /*****************************************************************************
47 * Private functions
48 ****************************************************************************/
49
50 /*****************************************************************************
51 * Public functions
52 ****************************************************************************/
53
54 /* Initialize the LCD controller */
55 void Chip_LCD_Init(LPC_LCD_T *pLCD, LCD_Config_T *LCD_ConfigStruct)
56 {
57 Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_LCD);
58 IP_LCD_Init(pLCD, LCD_ConfigStruct);
59 }
60
61 /* Shutdown the LCD controller */
62 void Chip_LCD_DeInit(LPC_LCD_T *pLCD)
63 {
64 Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_LCD);
65 }
66
67 /* Configure Cursor */
68 void Chip_LCD_Cursor_Config(LPC_LCD_T *pLCD, IP_LCD_CURSOR_SIZE_OPT_T cursor_size, bool sync)
69 {
70 LCD_Cursor_Size = cursor_size;
71 IP_LCD_Cursor_Config(pLCD, cursor_size, sync);
72 }
73
74 /* Write Cursor Image into Internal Cursor Image Buffer */
75 void Chip_LCD_Cursor_WriteImage(LPC_LCD_T *pLCD, uint8_t cursor_num, void *Image)
76 {
77 int i, j;
78 uint32_t *fifoptr, *crsr_ptr = (uint32_t *) Image;
79
80 /* Check if Cursor Size was configured as 32x32 or 64x64*/
81 if (LCD_Cursor_Size == LCD_CURSOR_32x32) {
82 i = cursor_num * 64;
83 j = i + 64;
84 }
85 else {
86 i = 0;
87 j = 256;
88 }
89 fifoptr = IP_LCD_Cursor_GetImageBufferAddress(pLCD, 0);
90
91 /* Copy Cursor Image content to FIFO */
92 for (; i < j; i++) {
93
94 *fifoptr = *crsr_ptr;
95 crsr_ptr++;
96 fifoptr++;
97 }
98 }
99
100 /* Load LCD Palette */
101 void Chip_LCD_LoadPalette(LPC_LCD_T *pLCD, void *palette) {
102 LCD_PALETTE_ENTRY_T pal_entry, *ptr_pal_entry;
103 uint8_t i, *pal_ptr;
104
105 ptr_pal_entry = &pal_entry;
106 pal_ptr = (uint8_t *) palette;
107
108 /* 256 entry in the palette table */
109 for (i = 0; i < 256 / 2; i++) {
110 pal_entry.Bl = (*pal_ptr++) >> 3; /* blue first */
111 pal_entry.Gl = (*pal_ptr++) >> 3; /* get green */
112 pal_entry.Rl = (*pal_ptr++) >> 3; /* get red */
113 pal_ptr++; /* skip over the unused byte */
114 /* do the most significant halfword of the palette */
115 pal_entry.Bu = (*pal_ptr++) >> 3; /* blue first */
116 pal_entry.Gu = (*pal_ptr++) >> 3; /* get green */
117 pal_entry.Ru = (*pal_ptr++) >> 3; /* get red */
118 pal_ptr++; /* skip over the unused byte */
119
120 IP_LCD_Color_LoadPalette(pLCD, (uint32_t *) &ptr_pal_entry, i);
121 }
122 }
123
124 #endif /* !defined(CHIP_LPC175X_6X) */