Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * Custom display controller driver template |
||
4 | ***************************************************************************** |
||
5 | * FileName: MicrochipGraphicsModule.h |
||
6 | * Dependencies: p24Fxxxx.h or plib.h |
||
7 | * Processor: PIC24F |
||
8 | * Compiler: MPLAB C30 |
||
9 | * Linker: MPLAB LINK30 |
||
10 | * Company: Microchip Technology Incorporated |
||
11 | * |
||
12 | * Software License Agreement |
||
13 | * |
||
14 | * Copyright © 2008 Microchip Technology Inc. All rights reserved. |
||
15 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
16 | * Software only when embedded on a Microchip microcontroller or digital |
||
17 | * signal controller, which is integrated into your product or third party |
||
18 | * product (pursuant to the sublicense terms in the accompanying license |
||
19 | * agreement). |
||
20 | * |
||
21 | * You should refer to the license agreement accompanying this Software |
||
22 | * for additional information regarding your rights and obligations. |
||
23 | * |
||
24 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
25 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
26 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
27 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
28 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
29 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
30 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
31 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
32 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
33 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
34 | * OR OTHER SIMILAR COSTS. |
||
35 | * |
||
36 | * Author Date Comment |
||
37 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
38 | * Pradeep Budagutta 20 Aug 2009 Initial Version |
||
39 | * Pradeep Budagutta 03 Dec 2009 Added Double Buffering Support |
||
40 | *****************************************************************************/ |
||
41 | #ifndef _CUSTOM_DISPLAY_DRIVER_H |
||
42 | #define _CUSTOM_DISPLAY_DRIVER_H |
||
43 | |||
44 | #ifdef __PIC32MX |
||
45 | #include <plib.h> |
||
46 | #define PMDIN1 PMDIN |
||
47 | #else |
||
48 | #ifdef __PIC24F__ |
||
49 | #include <p24Fxxxx.h> |
||
50 | #else |
||
51 | #error CONTROLLER IS NOT SUPPORTED |
||
52 | #endif |
||
53 | #endif |
||
54 | |||
55 | #include "GraphicsConfig.h" |
||
56 | #include "GenericTypeDefs.h" |
||
57 | |||
58 | /********************************************************************* |
||
59 | * Overview: Additional hardware-accelerated functions can be implemented |
||
60 | * in the driver. These definitions exclude the PutPixel()-based |
||
61 | * functions in the primitives layer (Primitive.c file) from compilation. |
||
62 | *********************************************************************/ |
||
63 | |||
64 | // Define this to implement Font related functions in the driver. |
||
65 | #if (DISP_ORIENTATION == 0) |
||
66 | // #define USE_DRV_FONT |
||
67 | #endif |
||
68 | |||
69 | // Define this to implement Line function in the driver. |
||
70 | #define USE_DRV_LINE |
||
71 | |||
72 | // Define this to implement Circle function in the driver. |
||
73 | //#define USE_DRV_CIRCLE |
||
74 | |||
75 | // Define this to implement FillCircle function in the driver. |
||
76 | //#define USE_DRV_FILLCIRCLE |
||
77 | |||
78 | // Define this to implement Bar function in the driver. |
||
79 | #define USE_DRV_BAR |
||
80 | |||
81 | // Define this to implement ClearDevice function in the driver. |
||
82 | #define USE_DRV_CLEARDEVICE |
||
83 | |||
84 | // Define this to implement PutImage function in the driver. |
||
85 | #define USE_DRV_PUTIMAGE |
||
86 | |||
87 | #ifndef DISP_HOR_RESOLUTION |
||
88 | #error DISP_HOR_RESOLUTION must be defined in GraphicsConfig.h |
||
89 | #endif |
||
90 | |||
91 | #ifndef DISP_VER_RESOLUTION |
||
92 | #error DISP_VER_RESOLUTION must be defined in GraphicsConfig.h |
||
93 | #endif |
||
94 | |||
95 | #ifndef COLOR_DEPTH |
||
96 | #error COLOR_DEPTH must be defined in GraphicsConfig.h |
||
97 | #endif |
||
98 | |||
99 | #ifndef DISP_ORIENTATION |
||
100 | #error DISP_ORIENTATION must be defined in GraphicsConfig.h |
||
101 | #endif |
||
102 | |||
103 | /********************************************************************* |
||
104 | * Overview: Clipping region control codes to be used with SetClip(...) |
||
105 | * function. |
||
106 | *********************************************************************/ |
||
107 | #define CLIP_DISABLE 0 // Disables clipping. |
||
108 | #define CLIP_ENABLE 1 // Enables clipping. |
||
109 | |||
110 | /********************************************************************* |
||
111 | * Overview: Some basic colors definitions. |
||
112 | *********************************************************************/ |
||
113 | #ifdef USE_PALETTE |
||
114 | |||
115 | #include "PaletteColorDefines.h" |
||
116 | |||
117 | #elif (COLOR_DEPTH == 16) |
||
118 | |||
119 | #define BLACK RGB565CONVERT(0, 0, 0) |
||
120 | #define BRIGHTBLUE RGB565CONVERT(0, 0, 255) |
||
121 | #define BRIGHTGREEN RGB565CONVERT(0, 255, 0) |
||
122 | #define BRIGHTCYAN RGB565CONVERT(0, 255, 255) |
||
123 | #define BRIGHTRED RGB565CONVERT(255, 0, 0) |
||
124 | #define BRIGHTMAGENTA RGB565CONVERT(255, 0, 255) |
||
125 | #define BRIGHTYELLOW RGB565CONVERT(255, 255, 0) |
||
126 | #define BLUE RGB565CONVERT(0, 0, 128) |
||
127 | #define GREEN RGB565CONVERT(0, 128, 0) |
||
128 | #define CYAN RGB565CONVERT(0, 128, 128) |
||
129 | #define RED RGB565CONVERT(128, 0, 0) |
||
130 | #define MAGENTA RGB565CONVERT(128, 0, 128) |
||
131 | #define BROWN RGB565CONVERT(255, 128, 0) |
||
132 | #define LIGHTGRAY RGB565CONVERT(128, 128, 128) |
||
133 | #define DARKGRAY RGB565CONVERT(64, 64, 64) |
||
134 | #define LIGHTBLUE RGB565CONVERT(128, 128, 255) |
||
135 | #define LIGHTGREEN RGB565CONVERT(128, 255, 128) |
||
136 | #define LIGHTCYAN RGB565CONVERT(128, 255, 255) |
||
137 | #define LIGHTRED RGB565CONVERT(255, 128, 128) |
||
138 | #define LIGHTMAGENTA RGB565CONVERT(255, 128, 255) |
||
139 | #define YELLOW RGB565CONVERT(255, 255, 128) |
||
140 | #define WHITE RGB565CONVERT(255, 255, 255) |
||
141 | |||
142 | #define GRAY0 RGB565CONVERT(224, 224, 224) |
||
143 | #define GRAY1 RGB565CONVERT(192, 192, 192) |
||
144 | #define GRAY2 RGB565CONVERT(160, 160, 160) |
||
145 | #define GRAY3 RGB565CONVERT(128, 128, 128) |
||
146 | #define GRAY4 RGB565CONVERT(96, 96, 96) |
||
147 | #define GRAY5 RGB565CONVERT(64, 64, 64) |
||
148 | #define GRAY6 RGB565CONVERT(32, 32, 32) |
||
149 | |||
150 | #elif (COLOR_DEPTH == 8) |
||
151 | |||
152 | #define BLACK RGB332CONVERT(0, 0, 0) |
||
153 | #define BRIGHTBLUE RGB332CONVERT(0, 0, 255) |
||
154 | #define BRIGHTGREEN RGB332CONVERT(0, 255, 0) |
||
155 | #define BRIGHTCYAN RGB332CONVERT(0, 255, 255) |
||
156 | #define BRIGHTRED RGB332CONVERT(255, 0, 0) |
||
157 | #define BRIGHTMAGENTA RGB332CONVERT(255, 0, 255) |
||
158 | #define BRIGHTYELLOW RGB332CONVERT(255, 255, 0) |
||
159 | #define BLUE RGB332CONVERT(0, 0, 128) |
||
160 | #define GREEN RGB332CONVERT(0, 128, 0) |
||
161 | #define CYAN RGB332CONVERT(0, 128, 128) |
||
162 | #define RED RGB332CONVERT(128, 0, 0) |
||
163 | #define MAGENTA RGB332CONVERT(128, 0, 128) |
||
164 | #define BROWN RGB332CONVERT(255, 128, 0) |
||
165 | #define LIGHTGRAY RGB332CONVERT(128, 128, 128) |
||
166 | #define DARKGRAY RGB332CONVERT(64, 64, 64) |
||
167 | #define LIGHTBLUE RGB332CONVERT(128, 128, 255) |
||
168 | #define LIGHTGREEN RGB332CONVERT(128, 255, 128) |
||
169 | #define LIGHTCYAN RGB332CONVERT(128, 255, 255) |
||
170 | #define LIGHTRED RGB332CONVERT(255, 128, 128) |
||
171 | #define LIGHTMAGENTA RGB332CONVERT(255, 128, 255) |
||
172 | #define YELLOW RGB332CONVERT(255, 255, 128) |
||
173 | #define WHITE RGB332CONVERT(255, 255, 255) |
||
174 | |||
175 | #define GRAY0 RGB332CONVERT(224, 224, 224) |
||
176 | #define GRAY1 RGB332CONVERT(192, 192, 192) |
||
177 | #define GRAY2 RGB332CONVERT(160, 160, 160) |
||
178 | #define GRAY3 RGB332CONVERT(128, 128, 128) |
||
179 | #define GRAY4 RGB332CONVERT(96, 96, 96) |
||
180 | #define GRAY5 RGB332CONVERT(64, 64, 64) |
||
181 | #define GRAY6 RGB332CONVERT(32, 32, 32) |
||
182 | |||
183 | #elif (COLOR_DEPTH == 4) |
||
184 | |||
185 | #define BLACK 0x00 |
||
186 | #define BRIGHTBLUE 0x09 |
||
187 | #define BRIGHTGREEN 0x0C |
||
188 | #define BRIGHTCYAN 0x0D |
||
189 | #define BRIGHTRED 0x0A |
||
190 | #define BRIGHTMAGENTA 0x0B |
||
191 | #define BRIGHTYELLOW 0x0E |
||
192 | #define BLUE 0x09 |
||
193 | #define GREEN 0x0C |
||
194 | #define CYAN 0x0D |
||
195 | #define RED 0x0A |
||
196 | #define MAGENTA 0x0B |
||
197 | #define BROWN 0x02 |
||
198 | #define LIGHTGRAY 0x07 |
||
199 | #define DARKGRAY 0x07 |
||
200 | #define LIGHTBLUE 0x01 |
||
201 | #define LIGHTGREEN 0x04 |
||
202 | #define LIGHTCYAN 0x05 |
||
203 | #define LIGHTRED 0x02 |
||
204 | #define LIGHTMAGENTA 0x03 |
||
205 | #define YELLOW 0x06 |
||
206 | #define WHITE 0x0F |
||
207 | |||
208 | #define GRAY0 0x07 |
||
209 | #define GRAY1 0x07 |
||
210 | #define GRAY2 0x07 |
||
211 | #define GRAY3 0x07 |
||
212 | #define GRAY4 0x07 |
||
213 | #define GRAY5 0x07 |
||
214 | #define GRAY6 0x07 |
||
215 | |||
216 | #elif (COLOR_DEPTH == 2) |
||
217 | |||
218 | #define BLACK 0x00 |
||
219 | #define BRIGHTBLUE 0x03 |
||
220 | #define BRIGHTGREEN 0x03 |
||
221 | #define BRIGHTCYAN 0x03 |
||
222 | #define BRIGHTRED 0x03 |
||
223 | #define BRIGHTMAGENTA 0x03 |
||
224 | #define BRIGHTYELLOW 0x03 |
||
225 | #define BLUE 0x02 |
||
226 | #define GREEN 0x02 |
||
227 | #define CYAN 0x02 |
||
228 | #define RED 0x02 |
||
229 | #define MAGENTA 0x02 |
||
230 | #define BROWN 0x02 |
||
231 | #define LIGHTGRAY 0x02 |
||
232 | #define DARKGRAY 0x01 |
||
233 | #define LIGHTBLUE 0x01 |
||
234 | #define LIGHTGREEN 0x01 |
||
235 | #define LIGHTCYAN 0x01 |
||
236 | #define LIGHTRED 0x01 |
||
237 | #define LIGHTMAGENTA 0x01 |
||
238 | #define YELLOW 0x01 |
||
239 | #define WHITE 0x03 |
||
240 | |||
241 | #define GRAY0 0x02 |
||
242 | #define GRAY1 0x02 |
||
243 | #define GRAY2 0x02 |
||
244 | #define GRAY3 0x01 |
||
245 | #define GRAY4 0x01 |
||
246 | #define GRAY5 0x01 |
||
247 | #define GRAY6 0x01 |
||
248 | |||
249 | #elif (COLOR_DEPTH == 1) |
||
250 | |||
251 | #define BLACK 0x00 |
||
252 | #define BRIGHTBLUE 0x01 |
||
253 | #define BRIGHTGREEN 0x01 |
||
254 | #define BRIGHTCYAN 0x01 |
||
255 | #define BRIGHTRED 0x01 |
||
256 | #define BRIGHTMAGENTA 0x01 |
||
257 | #define BRIGHTYELLOW 0x01 |
||
258 | #define BLUE 0x01 |
||
259 | #define GREEN 0x01 |
||
260 | #define CYAN 0x01 |
||
261 | #define RED 0x01 |
||
262 | #define MAGENTA 0x01 |
||
263 | #define BROWN 0x01 |
||
264 | #define LIGHTGRAY 0x00 |
||
265 | #define DARKGRAY 0x00 |
||
266 | #define LIGHTBLUE 0x00 |
||
267 | #define LIGHTGREEN 0x00 |
||
268 | #define LIGHTCYAN 0x00 |
||
269 | #define LIGHTRED 0x00 |
||
270 | #define LIGHTMAGENTA 0x00 |
||
271 | #define YELLOW 0x00 |
||
272 | #define WHITE 0x00 |
||
273 | |||
274 | #define GRAY0 0x01 |
||
275 | #define GRAY1 0x01 |
||
276 | #define GRAY2 0x01 |
||
277 | #define GRAY3 0x01 |
||
278 | #define GRAY4 0x00 |
||
279 | #define GRAY5 0x00 |
||
280 | #define GRAY6 0x00 |
||
281 | |||
282 | #endif // Color |
||
283 | |||
284 | extern WORD_VAL _color; |
||
285 | extern WORD_VAL _chrcolor; |
||
286 | |||
287 | /********************************************************************* |
||
288 | * Overview: Clipping region control and border settings. |
||
289 | * |
||
290 | *********************************************************************/ |
||
291 | // Clipping region enable control |
||
292 | extern SHORT _clipRgn; |
||
293 | // Left clipping region border |
||
294 | extern SHORT _clipLeft; |
||
295 | // Top clipping region border |
||
296 | extern SHORT _clipTop; |
||
297 | // Right clipping region border |
||
298 | extern SHORT _clipRight; |
||
299 | // Bottom clipping region border |
||
300 | extern SHORT _clipBottom; |
||
301 | |||
302 | #define GFX_LCD_TFT 0x01 |
||
303 | #define GFX_LCD_MSTN 0x02 |
||
304 | #define GFX_LCD_CSTN 0x03 |
||
305 | #define GFX_LCD_OFF 0x00 |
||
306 | |||
307 | #define STN_DISPLAY_WIDTH_4 0x00 |
||
308 | #define STN_DISPLAY_WIDTH_8 0x01 |
||
309 | #define STN_DISPLAY_WIDTH_16 0x02 |
||
310 | |||
311 | #define GFX_1_BPP 0x00 |
||
312 | #define GFX_2_BPP 0x01 |
||
313 | #define GFX_4_BPP 0x02 |
||
314 | #define GFX_8_BPP 0x03 |
||
315 | #define GFX_16_BPP 0x04 |
||
316 | |||
317 | #if (COLOR_DEPTH == 1) |
||
318 | #define GFX_BITS_PER_PIXEL GFX_1_BPP |
||
319 | #define GFX_COLOR_MASK 0x0001 |
||
320 | #elif (COLOR_DEPTH == 2) |
||
321 | #define GFX_BITS_PER_PIXEL GFX_2_BPP |
||
322 | #define GFX_COLOR_MASK 0x0003 |
||
323 | #elif (COLOR_DEPTH == 4) |
||
324 | #define GFX_BITS_PER_PIXEL GFX_4_BPP |
||
325 | #define GFX_COLOR_MASK 0x000F |
||
326 | #elif (COLOR_DEPTH == 8) |
||
327 | #define GFX_BITS_PER_PIXEL GFX_8_BPP |
||
328 | #define GFX_COLOR_MASK 0x00FF |
||
329 | #else |
||
330 | #define GFX_BITS_PER_PIXEL GFX_16_BPP |
||
331 | #define GFX_COLOR_MASK 0xFFFF |
||
332 | #endif |
||
333 | |||
334 | #define GFX_COMMAND_QUEUE_LENGTH 16 |
||
335 | |||
336 | #define GFX_ACTIVE_HIGH 1 |
||
337 | #define GFX_ACTIVE_LOW 0 |
||
338 | |||
339 | /* RCC GPU Commands */ |
||
340 | #define RCC_SRCADDR 0x62000000ul |
||
341 | #define RCC_DESTADDR 0x63000000ul |
||
342 | #define RCC_RECTSIZE 0x64000000ul |
||
343 | #define RCC_COLOR 0x66000000ul |
||
344 | #define RCC_STARTCOPY 0x67000000ul |
||
345 | |||
346 | #define RCC_SOLID_FILL 0x00000000ul |
||
347 | #define RCC_COPY 0x00000080ul |
||
348 | #define RCC_TRANSPARENT_COPY 0x00000300ul |
||
349 | |||
350 | #define RCC_ROP_0 0x00000000ul |
||
351 | #define RCC_ROP_1 0x00000008ul |
||
352 | #define RCC_ROP_2 0x00000010ul |
||
353 | #define RCC_ROP_3 0x00000018ul |
||
354 | #define RCC_ROP_4 0x00000020ul |
||
355 | #define RCC_ROP_5 0x00000028ul |
||
356 | #define RCC_ROP_6 0x00000030ul |
||
357 | #define RCC_ROP_7 0x00000038ul |
||
358 | #define RCC_ROP_8 0x00000040ul |
||
359 | #define RCC_ROP_9 0x00000048ul |
||
360 | #define RCC_ROP_A 0x00000050ul |
||
361 | #define RCC_ROP_B 0x00000058ul |
||
362 | #define RCC_ROP_C 0x00000060ul |
||
363 | #define RCC_ROP_D 0x00000068ul |
||
364 | #define RCC_ROP_E 0x00000070ul |
||
365 | #define RCC_ROP_F 0x00000078ul |
||
366 | |||
367 | #define RCC_SRC_ADDR_CONTINUOUS 0x00000002ul |
||
368 | #define RCC_SRC_ADDR_DISCONTINUOUS 0x00000000ul |
||
369 | #define RCC_DEST_ADDR_CONTINUOUS 0x00000004ul |
||
370 | #define RCC_DEST_ADDR_DISCONTINUOUS 0x00000000ul |
||
371 | |||
372 | #define GFX_SetCommand(c) { DWORD command = c; G1CMDL = ((DWORD_VAL)(command)).word.LW; G1CMDH = ((DWORD_VAL)(command)).word.HW; Nop(); } |
||
373 | |||
374 | #define GFX_SetDisplayArea(a) { DWORD address = a; G1DPADRL = ((DWORD_VAL)(address)).word.LW; G1DPADRH = ((DWORD_VAL)(address)).word.HW; } |
||
375 | #define GFX_SetWorkArea1(a) { DWORD address = a; G1W1ADRL = ((DWORD_VAL)(address)).word.LW; G1W1ADRH = ((DWORD_VAL)(address)).word.HW; } |
||
376 | #define GFX_SetWorkArea2(a) { DWORD address = a; G1W2ADRL = ((DWORD_VAL)(address)).word.LW; G1W2ADRH = ((DWORD_VAL)(address)).word.HW; } |
||
377 | |||
378 | #define GFX_SetSrcAddress(s) GFX_SetCommand(RCC_SRCADDR | (s)); /* Don't do error checking or error corrections */ |
||
379 | #define GFX_SetDestAddress(d) GFX_SetCommand(RCC_DESTADDR | (d)); /* Don't do error checking or error corrections */ |
||
380 | #define GFX_SetRectSize(width, height) GFX_SetCommand(RCC_RECTSIZE | (((DWORD)(width)) << 12) | (DWORD)height) /* Don't do error checking or error corrections */ |
||
381 | #define GFX_SetColor(color) GFX_SetCommand(RCC_COLOR | (color & GFX_COLOR_MASK)) /* Don't do error checking or error corrections */ |
||
382 | #define GFX_StartCopy(type_of_copy, rop, src_addr_type, dest_addr_type) GFX_SetCommand(RCC_STARTCOPY | type_of_copy | rop | src_addr_type | dest_addr_type) /* Don't do error checking or error corrections */ |
||
383 | |||
384 | #define CHR_FGCOLOR 0x50000000ul |
||
385 | #define CHR_BGCOLOR 0x51000000ul |
||
386 | #define CHR_FONTBASE 0x52000000ul |
||
387 | #define CHR_PRINTCHAR 0x53000000ul |
||
388 | #define CHR_TEXTAREASTART 0x58000000ul |
||
389 | #define CHR_TEXTAREAEND 0x59000000ul |
||
390 | #define CHR_PRINTPOS 0x5A000000ul |
||
391 | |||
392 | #define CHR_TRANSPARENT 0x00800000ul |
||
393 | #define CHR_OPAQUE 0x00000000ul |
||
394 | |||
395 | #define GFX_SetCharFgColor(color) { _chrcolor.Val = color; GFX_SetCommand(CHR_FGCOLOR | color); } |
||
396 | #define GFX_SetCharBgColor(color) GFX_SetCommand(CHR_BGCOLOR | color) |
||
397 | #define GFX_SetFont(fontaddress) GFX_SetCommand(CHR_FONTBASE | fontaddress) |
||
398 | #define GFX_SetStartXY(x, y) GFX_SetCommand(CHR_TEXTAREASTART | ((DWORD)x) << 12 | y) |
||
399 | #define GFX_SetEndXY(x, y) GFX_SetCommand(CHR_TEXTAREAEND | ((DWORD)x) << 12 | y) |
||
400 | #define GFX_SetPrintXY(x, y) GFX_SetCommand(CHR_PRINTPOS | ((DWORD)x) << 12 | y) |
||
401 | #define GFX_PrintChar(character, transparency) GFX_SetCommand(CHR_PRINTCHAR | transparency | character) |
||
402 | |||
403 | #define IPU_SRCOFFSET 0x71000000ul |
||
404 | #define IPU_DSTOFFSET 0x72000000ul |
||
405 | #define IPU_DSTSIZE 0x74000000ul |
||
406 | |||
407 | #define GFX_SetCompressedSource(address) GFX_SetCommand(IPU_SRCOFFSET | address) |
||
408 | #define GFX_SetDecompressionDest(address) GFX_SetCommand(IPU_DSTOFFSET | address) |
||
409 | #define GFX_SetDecompressSize(bytes) GFX_SetCommand(IPU_DSTSIZE | bytes) |
||
410 | #define GFX_FinalBlock() (G1IPU & 0x0001) |
||
411 | #define GFX_DecomperssionDone() (G1IPU & 0x0002) |
||
412 | #define GFX_DecompressionError() (G1IPU & 0x003C) |
||
413 | #define GFX_WrapAroundError() (G1IPU & 0x0004) |
||
414 | #define GFX_BlockLengthError() (G1IPU & 0x0008) |
||
415 | #define GFX_UndefinedBlockError() (G1IPU & 0x0010) |
||
416 | #define GFX_HuffmannError() (G1IPU & 0x0020) |
||
417 | |||
418 | #define GFX_GetFreeCommandSpace() (GFX_COMMAND_QUEUE_LENGTH - _GCMDCNT) |
||
419 | #define GFX_WaitForCommandQueue(n) while(GFX_GetFreeCommandSpace() < (n)); |
||
420 | #define GFX_IsRccGpuBusy() (_RCCBUSY) |
||
421 | #define GFX_IsIpuGpuBusy() (_IPUBUSY) |
||
422 | #define GFX_IsChrGpuBusy() (_CHRBUSY) |
||
423 | #define GFX_IsPuGpuBusy() (_PUBUSY) |
||
424 | #define GFX_WaitForRccGpu() while(_RCCBUSY); |
||
425 | #define GFX_WaitForIpuGpu() while(_IPUBUSY); |
||
426 | #define GFX_WaitForChrGpu() while(_CHRBUSY); |
||
427 | #define GFX_WaitForGpu() while(_PUBUSY); |
||
428 | |||
429 | /********************************************************************* |
||
430 | * Function: void ResetDevice() |
||
431 | * |
||
432 | * Overview: Initializes LCD module. |
||
433 | * |
||
434 | * PreCondition: none |
||
435 | * |
||
436 | * Input: none |
||
437 | * |
||
438 | * Output: none |
||
439 | * |
||
440 | * Side Effects: none |
||
441 | * |
||
442 | ********************************************************************/ |
||
443 | void ResetDevice(void); |
||
444 | |||
445 | /********************************************************************* |
||
446 | * Macros: GetMaxX() |
||
447 | * |
||
448 | * Overview: Returns maximum horizontal coordinate. |
||
449 | * |
||
450 | * PreCondition: none |
||
451 | * |
||
452 | * Input: none |
||
453 | * |
||
454 | * Output: Maximum horizontal coordinate. |
||
455 | * |
||
456 | * Side Effects: none |
||
457 | * |
||
458 | ********************************************************************/ |
||
459 | #if (DISP_ORIENTATION == 90) || (DISP_ORIENTATION == 270) |
||
460 | |||
461 | #define GetMaxX() (DISP_VER_RESOLUTION-1) |
||
462 | |||
463 | #elif (DISP_ORIENTATION == 0) || (DISP_ORIENTATION == 180) |
||
464 | |||
465 | #define GetMaxX() (DISP_HOR_RESOLUTION-1) |
||
466 | |||
467 | #endif |
||
468 | |||
469 | /********************************************************************* |
||
470 | * Macros: GetMaxY() |
||
471 | * |
||
472 | * Overview: Returns maximum vertical coordinate. |
||
473 | * |
||
474 | * PreCondition: none |
||
475 | * |
||
476 | * Input: none |
||
477 | * |
||
478 | * Output: Maximum vertical coordinate. |
||
479 | * |
||
480 | * Side Effects: none |
||
481 | * |
||
482 | ********************************************************************/ |
||
483 | #if (DISP_ORIENTATION == 90) || (DISP_ORIENTATION == 270) |
||
484 | |||
485 | #define GetMaxY() (DISP_HOR_RESOLUTION-1) |
||
486 | |||
487 | #elif (DISP_ORIENTATION == 0) || (DISP_ORIENTATION == 180) |
||
488 | |||
489 | #define GetMaxY() (DISP_VER_RESOLUTION-1) |
||
490 | |||
491 | #endif |
||
492 | |||
493 | /********************************************************************* |
||
494 | * Macros: SetColor(color) |
||
495 | * |
||
496 | * Overview: Sets current drawing color. |
||
497 | * |
||
498 | * PreCondition: none |
||
499 | * |
||
500 | * Input: color - Color coded in 5:6:5 RGB format. |
||
501 | * |
||
502 | * Output: none |
||
503 | * |
||
504 | * Side Effects: none |
||
505 | * |
||
506 | ********************************************************************/ |
||
507 | #define SetColor(color) _color.Val = color; |
||
508 | |||
509 | /********************************************************************* |
||
510 | * Macros: GetColor() |
||
511 | * |
||
512 | * Overview: Returns current drawing color. |
||
513 | * |
||
514 | * PreCondition: none |
||
515 | * |
||
516 | * Input: none |
||
517 | * |
||
518 | * Output: Color coded in 5:6:5 RGB format. |
||
519 | * |
||
520 | * Side Effects: none |
||
521 | * |
||
522 | ********************************************************************/ |
||
523 | #define GetColor() _color.Val |
||
524 | |||
525 | /********************************************************************* |
||
526 | * Macros: SetActivePage(page) |
||
527 | * |
||
528 | * Overview: Sets active graphic page. |
||
529 | * |
||
530 | * PreCondition: none |
||
531 | * |
||
532 | * Input: page - Graphic page number. |
||
533 | * |
||
534 | * Output: none |
||
535 | * |
||
536 | * Side Effects: none |
||
537 | * |
||
538 | ********************************************************************/ |
||
539 | #define SetActivePage(page) |
||
540 | |||
541 | /********************************************************************* |
||
542 | * Macros: SetVisualPage(page) |
||
543 | * |
||
544 | * Overview: Sets graphic page to display. |
||
545 | * |
||
546 | * PreCondition: none |
||
547 | * |
||
548 | * Input: page - Graphic page number |
||
549 | * |
||
550 | * Output: none |
||
551 | * |
||
552 | * Side Effects: none |
||
553 | * |
||
554 | ********************************************************************/ |
||
555 | #define SetVisualPage(page) |
||
556 | |||
557 | /********************************************************************* |
||
558 | * Function: WORD MoveBlock(DWORD srcAddr, DWORD dstAddr, |
||
559 | * DWORD srcOffset, DWORD dstOffset, |
||
560 | * WORD srcType, WORD dstType, |
||
561 | * WORD width, WORD height) |
||
562 | * |
||
563 | * PreCondition: none |
||
564 | * |
||
565 | * Input: srcAddr - the base address of the data to be moved |
||
566 | * dstAddr - the base address of the new location of the moved data |
||
567 | * srcOffset - offset of the data to be moved with respect to the |
||
568 | * source base address. |
||
569 | * dstOffset - offset of the new location of the moved data respect |
||
570 | * to the source base address. |
||
571 | * srcType - sets the source type (continuous or discontinuous) |
||
572 | * dstType - sets the source type (continuous or discontinuous) |
||
573 | * width - width of the block of data to be moved |
||
574 | * height - height of the block of data to be moved |
||
575 | * |
||
576 | * Output: none |
||
577 | * |
||
578 | * Side Effects: none |
||
579 | * |
||
580 | * Overview: puts pixel |
||
581 | * |
||
582 | * Note: none |
||
583 | * |
||
584 | ********************************************************************/ |
||
585 | WORD MoveBlock(DWORD srcAddr, DWORD dstAddr, DWORD srcOffset, DWORD dstOffset, |
||
586 | WORD srcType, WORD dstType, WORD width, WORD height); |
||
587 | |||
588 | /********************************************************************* |
||
589 | * Function: WORD ScrollLeft(SHORT left, SHORT top, |
||
590 | * SHORT right, SHORT bottom, SHORT delta) |
||
591 | * |
||
592 | * PreCondition: none |
||
593 | * |
||
594 | * Input: left - left position of the scrolled rectangle |
||
595 | * top - top position of the scrolled rectangle |
||
596 | * right - right position of the scrolled rectangle |
||
597 | * bottom - bottom position of the scrolled rectangle |
||
598 | * delta - defines the scroll delta |
||
599 | * |
||
600 | * Output: none |
||
601 | * |
||
602 | * Side Effects: none |
||
603 | * |
||
604 | * Overview: Scrolls the rectangular area defined by left, top, right, bottom by delta pixels. |
||
605 | * |
||
606 | * Note: none |
||
607 | * |
||
608 | ********************************************************************/ |
||
609 | WORD ScrollLeft(SHORT left, SHORT top, SHORT right, SHORT bottom, SHORT delta); |
||
610 | |||
611 | /********************************************************************* |
||
612 | * Function: void PutPixel(SHORT x, SHORT y) |
||
613 | * |
||
614 | * Overview: Puts pixel with the given x,y coordinate position. |
||
615 | * |
||
616 | * PreCondition: none |
||
617 | * |
||
618 | * Input: x - x position of the pixel. |
||
619 | * y - y position of the pixel. |
||
620 | * |
||
621 | * Output: none |
||
622 | * |
||
623 | * Side Effects: none |
||
624 | * |
||
625 | ********************************************************************/ |
||
626 | void PutPixel(SHORT x, SHORT y); |
||
627 | |||
628 | /********************************************************************* |
||
629 | * Function: WORD GetPixel(SHORT x, SHORT y) |
||
630 | * |
||
631 | * Overview: Returns pixel color at the given x,y coordinate position. |
||
632 | * |
||
633 | * PreCondition: none |
||
634 | * |
||
635 | * Input: x - x position of the pixel. |
||
636 | * y - y position of the pixel. |
||
637 | * |
||
638 | * Output: pixel color |
||
639 | * |
||
640 | * Side Effects: none |
||
641 | * |
||
642 | ********************************************************************/ |
||
643 | WORD GetPixel(SHORT x, SHORT y); |
||
644 | |||
645 | /********************************************************************* |
||
646 | * Function: SetClipRgn(left, top, right, bottom) |
||
647 | * |
||
648 | * Overview: Sets clipping region. |
||
649 | * |
||
650 | * PreCondition: none |
||
651 | * |
||
652 | * Input: left - Defines the left clipping region border. |
||
653 | * top - Defines the top clipping region border. |
||
654 | * right - Defines the right clipping region border. |
||
655 | * bottom - Defines the bottom clipping region border. |
||
656 | * |
||
657 | * Output: none |
||
658 | * |
||
659 | * Side Effects: none |
||
660 | * |
||
661 | ********************************************************************/ |
||
662 | void SetClipRgn(SHORT left, SHORT top, SHORT right, SHORT bottom); |
||
663 | |||
664 | /********************************************************************* |
||
665 | * Macros: GetClipLeft() |
||
666 | * |
||
667 | * Overview: Returns left clipping border. |
||
668 | * |
||
669 | * PreCondition: none |
||
670 | * |
||
671 | * Input: none |
||
672 | * |
||
673 | * Output: Left clipping border. |
||
674 | * |
||
675 | * Side Effects: none |
||
676 | * |
||
677 | ********************************************************************/ |
||
678 | #define GetClipLeft() _clipLeft |
||
679 | |||
680 | /********************************************************************* |
||
681 | * Macros: GetClipRight() |
||
682 | * |
||
683 | * Overview: Returns right clipping border. |
||
684 | * |
||
685 | * PreCondition: none |
||
686 | * |
||
687 | * Input: none |
||
688 | * |
||
689 | * Output: Right clipping border. |
||
690 | * |
||
691 | * Side Effects: none |
||
692 | * |
||
693 | ********************************************************************/ |
||
694 | #define GetClipRight() _clipRight |
||
695 | |||
696 | /********************************************************************* |
||
697 | * Macros: GetClipTop() |
||
698 | * |
||
699 | * Overview: Returns top clipping border. |
||
700 | * |
||
701 | * PreCondition: none |
||
702 | * |
||
703 | * Input: none |
||
704 | * |
||
705 | * Output: Top clipping border. |
||
706 | * |
||
707 | * Side Effects: none |
||
708 | * |
||
709 | ********************************************************************/ |
||
710 | #define GetClipTop() _clipTop |
||
711 | |||
712 | /********************************************************************* |
||
713 | * Macros: GetClipBottom() |
||
714 | * |
||
715 | * Overview: Returns bottom clipping border. |
||
716 | * |
||
717 | * PreCondition: none |
||
718 | * |
||
719 | * Input: none |
||
720 | * |
||
721 | * Output: Bottom clipping border. |
||
722 | * |
||
723 | * Side Effects: none |
||
724 | * |
||
725 | ********************************************************************/ |
||
726 | #define GetClipBottom() _clipBottom |
||
727 | |||
728 | /********************************************************************* |
||
729 | * Function: SetClip(control) |
||
730 | * |
||
731 | * Overview: Enables/disables clipping. |
||
732 | * |
||
733 | * PreCondition: none |
||
734 | * |
||
735 | * Input: control - Enables or disables the clipping. |
||
736 | * - 0: Disable clipping |
||
737 | * - 1: Enable clipping |
||
738 | * |
||
739 | * Output: none |
||
740 | * |
||
741 | * Side Effects: none |
||
742 | * |
||
743 | ********************************************************************/ |
||
744 | void SetClip(BYTE control); |
||
745 | |||
746 | /********************************************************************* |
||
747 | * Macros: IsDeviceBusy() |
||
748 | * |
||
749 | * Overview: Returns non-zero if LCD controller is busy |
||
750 | * (previous drawing operation is not completed). |
||
751 | * |
||
752 | * PreCondition: none |
||
753 | * |
||
754 | * Input: none |
||
755 | * |
||
756 | * Output: Busy status. |
||
757 | * |
||
758 | * Side Effects: none |
||
759 | * |
||
760 | ********************************************************************/ |
||
761 | #define IsDeviceBusy() (GFX_GetFreeCommandSpace() < 4) |
||
762 | |||
763 | /********************************************************************* |
||
764 | * Function: BYTE Decompress(DWORD SrcAddress, DWORD DestAddress, DWORD nbytes); |
||
765 | * |
||
766 | * Overview: Decompresses the nbytes number of data at SrcAddress and |
||
767 | * places starting from DestAddress. (Blocking) |
||
768 | * |
||
769 | * PreCondition: SrcAddress must point to the start of a compressed block. |
||
770 | * |
||
771 | * Input: SrcAddress - Source address |
||
772 | * DestAddress - Destination address |
||
773 | * nbytes - Number of bytes to be decompressed |
||
774 | * |
||
775 | * Output: error flag |
||
776 | * |
||
777 | * Side Effects: Modifies workarea_1 & workarea_2 registers. |
||
778 | * |
||
779 | ********************************************************************/ |
||
780 | BYTE Decompress(DWORD SrcAddress, DWORD DestAddress, DWORD nbytes); |
||
781 | |||
782 | typedef struct |
||
783 | { |
||
784 | WORD X; |
||
785 | WORD Y; |
||
786 | WORD W; |
||
787 | WORD H; |
||
788 | } RectangleArea; |
||
789 | |||
790 | #ifdef USE_DOUBLE_BUFFERING |
||
791 | |||
792 | #define GFX_MAX_INVALIDATE_AREAS 5 |
||
793 | |||
794 | extern BYTE blInvalidateAll; |
||
795 | extern BYTE blEnableDoubleBuffering; |
||
796 | extern volatile BYTE blDisplayUpdatePending; |
||
797 | extern BYTE NoOfInvalidatedRectangleAreas; |
||
798 | extern RectangleArea InvalidatedArea[GFX_MAX_INVALIDATE_AREAS]; |
||
799 | |||
800 | /********************************************************************* |
||
801 | * Macros: SwitchOnDoubleBuffering() |
||
802 | * |
||
803 | * Overview: Switches on the double buffering. |
||
804 | * The drawing is done on the draw buffer. |
||
805 | * This also causes copying of the frame buffer to draw buffer once. |
||
806 | * |
||
807 | * PreCondition: none |
||
808 | * |
||
809 | * Input: none |
||
810 | * |
||
811 | * Output: none |
||
812 | * |
||
813 | * Side Effects: none |
||
814 | * |
||
815 | ********************************************************************/ |
||
816 | #define SwitchOnDoubleBuffering() if(blEnableDoubleBuffering == 0) \ |
||
817 | { blEnableDoubleBuffering = 1; InvalidateAll(); } |
||
818 | |||
819 | /********************************************************************* |
||
820 | * Macros: SwitchOffDoubleBuffering() |
||
821 | * |
||
822 | * Overview: Switches off the double buffering. |
||
823 | * The drawing is done on the display buffer. |
||
824 | * |
||
825 | * PreCondition: none |
||
826 | * |
||
827 | * Input: none |
||
828 | * |
||
829 | * Output: none |
||
830 | * |
||
831 | * Side Effects: none |
||
832 | * |
||
833 | ********************************************************************/ |
||
834 | #define SwitchOffDoubleBuffering() if(blEnableDoubleBuffering == 1) \ |
||
835 | { UpdateDisplayNow(); \ |
||
836 | _drawbuffer = (_drawbuffer == GFX_BUFFER1)? GFX_BUFFER2: GFX_BUFFER1; \ |
||
837 | blEnableDoubleBuffering = 0; } |
||
838 | |||
839 | /********************************************************************* |
||
840 | * Macros: IsDisplayUpdatePending() |
||
841 | * |
||
842 | * Overview: Returns id the display updation is pending. |
||
843 | * |
||
844 | * PreCondition: none |
||
845 | * |
||
846 | * Input: none |
||
847 | * |
||
848 | * Output: none |
||
849 | * |
||
850 | * Side Effects: none |
||
851 | * |
||
852 | ********************************************************************/ |
||
853 | #define IsDisplayUpdatePending() blDisplayUpdatePending |
||
854 | |||
855 | /********************************************************************* |
||
856 | * Macros: InvalidateAll() |
||
857 | * |
||
858 | * Overview: Invalidates the whole screen |
||
859 | * |
||
860 | * PreCondition: none |
||
861 | * |
||
862 | * Input: none |
||
863 | * |
||
864 | * Output: none |
||
865 | * |
||
866 | * Side Effects: none |
||
867 | * |
||
868 | ********************************************************************/ |
||
869 | #define InvalidateAll() blInvalidateAll = 1; |
||
870 | |||
871 | /********************************************************************* |
||
872 | * Function: void InvalidateRectangle(WORD left, WORD top, WORD right, WORD bottom) |
||
873 | * |
||
874 | * Overview: Invalidates the specified rectangular area and if the |
||
875 | * invalidated areas exceed the GFX_MAX_INVALIDATE_AREAS, |
||
876 | * whole area is marked as invalidate |
||
877 | * |
||
878 | * PreCondition: None |
||
879 | * |
||
880 | * Input: left,top - top left corner coordinates, |
||
881 | * right,bottom - bottom right corner coordinates |
||
882 | * |
||
883 | * Output: None |
||
884 | * |
||
885 | * Side Effects: Only copies back the invalidated areas to the draw - |
||
886 | * buffer after the exchange of draw and frame buffers |
||
887 | * |
||
888 | ********************************************************************/ |
||
889 | void InvalidateRectangle(WORD x, WORD y, WORD w, WORD h); |
||
890 | |||
891 | /********************************************************************* |
||
892 | * Function: void UpdateDisplayNow(void) |
||
893 | * |
||
894 | * Overview: Synchronizes the draw and frame buffers immediately |
||
895 | * |
||
896 | * PreCondition: none |
||
897 | * |
||
898 | * Input: none |
||
899 | * |
||
900 | * Output: none |
||
901 | * |
||
902 | * Side Effects: none |
||
903 | * |
||
904 | ********************************************************************/ |
||
905 | void UpdateDisplayNow(void); |
||
906 | |||
907 | /********************************************************************* |
||
908 | * Function: void RequestDisplayUpdate(void) |
||
909 | * |
||
910 | * Overview: Synchronizes the draw and frame buffers at next VBlank |
||
911 | * |
||
912 | * PreCondition: none |
||
913 | * |
||
914 | * Input: none |
||
915 | * |
||
916 | * Output: none |
||
917 | * |
||
918 | * Side Effects: none |
||
919 | * |
||
920 | ********************************************************************/ |
||
921 | void RequestDisplayUpdate(void); |
||
922 | |||
923 | #else |
||
924 | |||
925 | #define SwitchOnDoubleBuffering() |
||
926 | #define SwitchOffDoubleBuffering() |
||
927 | #define IsDisplayUpdatePending() 0 |
||
928 | #define InvalidateAll() |
||
929 | #define InvalidateRectangle(x, y, w, h) |
||
930 | #define ExchangeDrawAndFrameBuffers() |
||
931 | #define UpdateDisplayNow() |
||
932 | #define RequestDisplayUpdate() |
||
933 | |||
934 | #endif //USE_DOUBLE_BUFFERING |
||
935 | |||
936 | #ifdef USE_PALETTE |
||
937 | #include "Graphics\Palette.h" |
||
938 | #endif |
||
939 | |||
940 | #endif // _CUSTOM_DISPLAY_DRIVER_H |
Powered by WebSVN v2.8.3