LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 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 Hello World 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 
58 /*****************************************************************************
59  * Private types/enumerations/variables
60  ****************************************************************************/
61 
62 /* LCD width and height (from board LCD setup descriptor) */
63 #define LCD_WIDTH BOARD_LCD.PPL
64 #define LCD_HEIGHT BOARD_LCD.LPP
65 
66 #if defined(__IAR_SYSTEMS_ICC__)
67  #define LOCATE_ATX(x) _Pragma(#x)
68  #define LOCATE_ATXX(x) LOCATE_ATX(location=x)
69  #define LOCATE_AT(x) LOCATE_ATXX(x)
70 #elif defined(__ARMCC_VERSION)
71  #define LOCATE_AT(x) __attribute__ ((at(x)))
72 #elif (defined(__CODE_RED))
73  #define LOCATE_ATX(x) __attribute__((section(".shmem_"#x ",\"aw\",%nobits@")))
74  #define LOCATE_AT(x) LOCATE_ATX(x)
75 #elif (defined(__CODE_RED))
76  #define LOCATE_AT(x) LOCATE_ATX(x)
77 #endif
78 
79 /*****************************************************************************
80  * Public types/enumerations/variables
81  ****************************************************************************/
82 
86 #define GUI_BUF LOCATE_AT(GUI_BUF_ADDR)
87 #define GUI_BUF_ADDR 0x28050000
88 #define GUI_NUMBYTES ((1024 * 1024) * 2)
90 U32 GUI_Block_Size = 0x128;
91 GUI_BUF U32 GUI_Memory[GUI_NUMBYTES / sizeof(U32)];
92 
97 
98 /*****************************************************************************
99  * Private functions
100  ****************************************************************************/
101 
102 /* mSec delay */
103 static void lcdDelay(uint32_t delay)
104 {
105  delay += systick_timems;
106  while (systick_timems < delay) {}
107 }
108 
109 /* Initialize the LCD for the current board */
110 static void lcdInit(void)
111 {
112  /* Board specific LCD pre-setup */
113  Board_LCD_Init();
114 
115  /* Setup for current board */
119  lcdDelay(100);
120 
121  /* Turn on backlight */
123 }
124 
125 /*****************************************************************************
126  * Public functions
127  ****************************************************************************/
128 
133 void SysTick_Handler(void)
134 {
135  systick_timems++;
136 }
137 
142 int main(void)
143 {
144  int xPos, yPos, xSize;
145  int i = 0;
146 
147  Board_Init();
148 
149  /* sysTick will handle touch events at 1KHz */
150  SysTick_Config(Chip_Clock_GetRate(CLK_MX_MXCORE) / 1000);
151 
152  /* Setup LCD */
153  lcdInit();
154 
155  /* emWin start */
156  GUI_Init();
157 
158  /* Solid color display */
159  GUI_SetBkColor(GUI_RED);
160  GUI_Clear();
161  GUI_Delay(1000);
162  GUI_SetBkColor(GUI_GREEN);
163  GUI_Clear();
164  GUI_Delay(1000);
165  GUI_SetBkColor(GUI_BLUE);
166  GUI_Clear();
167  GUI_Delay(1000);
168  GUI_SetBkColor(GUI_BLACK);
169  GUI_Clear();
170 
171  xPos = LCD_GetXSize() / 2;
172  yPos = LCD_GetYSize() / 3;
173  GUI_SetColor(GUI_BROWN);
174  GUI_SetTextMode(GUI_TM_REV);
175  GUI_SetFont(GUI_FONT_20F_ASCII);
176  GUI_DispStringHCenterAt("Hello NXP", xPos, yPos);
177  GUI_SetFont(GUI_FONT_D24X32);
178  GUI_SetColor(GUI_LIGHTYELLOW);
179  xSize = GUI_GetStringDistX("0000");
180  xPos -= xSize / 2;
181  yPos += 24 + 10;
182  while (1) {
183  GUI_DispDecAt(i++, xPos, yPos, 4);
184  if (i > 9999) {
185  i = 0;
186  }
187 
188  GUI_Delay(10);
189  }
190 }
191