| 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
main.c
Go to the documentation of this file.
1 /*
2 * @brief emWin with touch example
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 "GUI.h"
33 #include "board.h"
34
59 /*****************************************************************************
60 * Private types/enumerations/variables
61 ****************************************************************************/
62
63 /* LCD width and height (from board LCD setup descriptor) */
64 #define LCD_WIDTH BOARD_LCD.PPL
65 #define LCD_HEIGHT BOARD_LCD.LPP
66
67 #if defined(__IAR_SYSTEMS_ICC__)
68 #define LOCATE_ATX(x) _Pragma(#x)
69 #define LOCATE_ATXX(x) LOCATE_ATX(location=x)
70 #define LOCATE_AT(x) LOCATE_ATXX(x)
71 #elif defined(__ARMCC_VERSION)
72 #define LOCATE_AT(x) __attribute__ ((at(x)))
73 #elif (defined(__CODE_RED))
74 #define LOCATE_ATX(x) __attribute__((section(".shmem_"#x ",\"aw\",%nobits@")))
75 #define LOCATE_AT(x) LOCATE_ATX(x)
76 #elif (defined(__CODE_RED))
77 #define LOCATE_AT(x) LOCATE_ATX(x)
78 #endif
79
80 static int16_t old_tmp_x = -1, old_tmp_y = -1;
81
82 /*****************************************************************************
83 * Public types/enumerations/variables
84 ****************************************************************************/
85
89 #define GUI_BUF LOCATE_AT(GUI_BUF_ADDR)
90 #define GUI_BUF_ADDR 0x28050000
91 #define GUI_NUMBYTES ((1024 * 1024) * 2)
92 U32 GUI_Memory_Size = GUI_NUMBYTES;
93 U32 GUI_Block_Size = 0x128;
94 GUI_BUF U32 GUI_Memory[GUI_NUMBYTES / sizeof(U32)];
95
99 volatile uint32_t systick_timems;
100
101 /*****************************************************************************
102 * Private functions
103 ****************************************************************************/
104
105 /* mSec delay */
106 static void lcdDelay(uint32_t delay)
107 {
108 delay += systick_timems;
109 while (systick_timems < delay) {}
110 }
111
112 /* Initialize the LCD for the current board */
113 static void lcdInit(void)
114 {
115 /* Board specific LCD pre-setup */
116 Board_LCD_Init();
117
118 /* Setup for current board */
119 Chip_LCD_Init(LPC_LCD, (LCD_Config_T *) &BOARD_LCD);
120 Board_InitTouchController();
121 Chip_LCD_SetUPFrameBuffer(LPC_LCD, (void *) FRAMEBUFFER_ADDR);
122 Chip_LCD_PowerOn(LPC_LCD);
123 lcdDelay(100);
124
125 /* Turn on backlight */
126 Board_SetLCDBacklight(1);
127 }
128
129 /*****************************************************************************
130 * Public functions
131 ****************************************************************************/
132
137 void SysTick_Handler(void) // SysTick Interrupt Handler @ 1000Hz
138 {
139 static uint8_t ttick = 0; // Touch Screen time tick
140 int16_t tmp_x = -1, tmp_y = -1;
141 int16_t tmp_x1 = -1, tmp_y1 = -1;
142 systick_timems++; // Increment 1ms time tick
143
144 if (ttick++ == 20) { // Touch Screen update period is 20ms
145 ttick = 0;
146 Board_GetTouchPos((int16_t *) &tmp_x, (int16_t *) &tmp_y);
147 if ((tmp_x >= 0) && (tmp_y > 0) && ((tmp_x != old_tmp_x) || (tmp_y != old_tmp_y))) {
148 tmp_x1 = tmp_y;
149 tmp_y1 = tmp_x;
150 GUI_TOUCH_StoreState(320 - tmp_x1, tmp_y1);
151 old_tmp_x = tmp_x;
152 old_tmp_y = tmp_y;
153 }
154 else {
155 GUI_TOUCH_StoreState(-1, -1);
156 }
157 }
158 }
159
160 extern void MainTask(void);
161
166 int main(void)
167 {
168 Board_Init();
169
170 /* sysTick will handle touch events at 1KHz */
171 SysTick_Config(Chip_Clock_GetRate(CLK_MX_MXCORE) / 1000);
172
173 /* Setup LCD */
174 lcdInit();
175
176 /* Main Task */
177 MainTask();
178
179 return 0;
180 }
181