These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GLCD_SPI_LPC1700.c Source File

GLCD_SPI_LPC1700.c

00001 /******************************************************************************/
00002 /* GLCD_SPI_LPC1700.c: LPC1700 low level Graphic LCD (320x240 pixels) driven  */
00003 /*                     with SPI functions                                     */
00004 /******************************************************************************/
00005 /* This file is part of the uVision/ARM development tools.                    */
00006 /* Copyright (c) 2005-2009 Keil Software. All rights reserved.                */
00007 /* This software may only be used under the terms of a valid, current,        */
00008 /* end user licence from KEIL for a compatible version of KEIL software       */
00009 /* development tools. Nothing else gives you the right to use this software.  */
00010 /******************************************************************************/
00011 
00012 
00013 #include <lpc17xx.h>
00014 #include "GLCD.h"
00015 #include "Font_24x16.h"
00016 
00017 /*********************** Hardware specific configuration **********************/
00018 
00019 /* SPI Interface: SPI3
00020 
00021    PINS:
00022    - CS     = P0.6 (GPIO pin)
00023    - RS     = GND
00024    - WR/SCK = P0.7 (SCK1)
00025    - RD     = GND
00026    - SDO    = P0.8 (MISO1)
00027    - SDI    = P0.9 (MOSI1)                                                    */
00028 
00029 #define PIN_CS      (1 << 6)
00030 
00031 /* SPI_SR - bit definitions                                                   */
00032 #define TFE         0x01
00033 #define RNE         0x04
00034 #define BSY         0x10
00035 
00036 /*------------------------- Speed dependant settings -------------------------*/
00037 
00038 /* If processor works on high frequency delay has to be increased, it can be
00039    increased by factor 2^N by this constant                                   */
00040 #define DELAY_2N    18
00041 
00042 /*---------------------- Graphic LCD size definitions ------------------------*/
00043 
00044 #define WIDTH       320                 /* Screen Width (in pixels)           */
00045 #define HEIGHT      240                 /* Screen Hight (in pixels)           */
00046 #define BPP         16                  /* Bits per pixel                     */
00047 #define BYPP        ((BPP+7)/8)         /* Bytes per pixel                    */
00048 
00049 /*--------------- Graphic LCD interface hardware definitions -----------------*/
00050 
00051 /* Pin CS setting to 0 or 1                                                   */
00052 #define LCD_CS(x)   ((x) ? (LPC_GPIO0->FIOSET = PIN_CS) : (LPC_GPIO0->FIOCLR = PIN_CS));
00053 
00054 #define SPI_START   (0x70)              /* Start byte for SPI transfer        */
00055 #define SPI_RD      (0x01)              /* WR bit 1 within start              */
00056 #define SPI_WR      (0x00)              /* WR bit 0 within start              */
00057 #define SPI_DATA    (0x02)              /* RS bit 1 within start byte         */
00058 #define SPI_INDEX   (0x00)              /* RS bit 0 within start byte         */
00059 
00060 /*---------------------------- Global variables ------------------------------*/
00061 
00062 /******************************************************************************/
00063 static volatile unsigned short TextColor = Black, BackColor = White;
00064 
00065 
00066 /************************ Local auxiliary functions ***************************/
00067 
00068 /*******************************************************************************
00069 * Delay in while loop cycles                                                   *
00070 *   Parameter:    cnt:    number of while cycles to delay                      *
00071 *   Return:                                                                    *
00072 *******************************************************************************/
00073 
00074 static void delay (int cnt) {
00075 
00076   cnt <<= DELAY_2N;
00077   while (cnt--);
00078 }
00079 
00080 
00081 /*******************************************************************************
00082 * Send 1 byte over serial communication                                        *
00083 *   Parameter:    byte:   byte to be sent                                      *
00084 *   Return:               byte read while sending                              *
00085 *******************************************************************************/
00086 
00087 static __INLINE unsigned char spi_send (unsigned char byte) {
00088 
00089   LPC_SSP1->DR = byte;
00090   while (!(LPC_SSP1->SR & RNE));        /* Wait for send to finish            */
00091   return (LPC_SSP1->DR);
00092 }
00093 
00094 
00095 /*******************************************************************************
00096 * Write command to LCD controller                                              *
00097 *   Parameter:    c:      command to be written                                *
00098 *   Return:                                                                    *
00099 *******************************************************************************/
00100 
00101 static __INLINE void wr_cmd (unsigned char c) {
00102 
00103   LCD_CS(0)
00104   spi_send(SPI_START | SPI_WR | SPI_INDEX);   /* Write : RS = 0, RW = 0       */
00105   spi_send(0);
00106   spi_send(c);
00107   LCD_CS(1)
00108 }
00109 
00110 
00111 /*******************************************************************************
00112 * Write data to LCD controller                                                 *
00113 *   Parameter:    c:      data to be written                                   *
00114 *   Return:                                                                    *
00115 *******************************************************************************/
00116 
00117 static __INLINE void wr_dat (unsigned short c) {
00118 
00119   LCD_CS(0)
00120   spi_send(SPI_START | SPI_WR | SPI_DATA);    /* Write : RS = 1, RW = 0       */
00121   spi_send((c >>   8));                       /* Write D8..D15                */
00122   spi_send((c & 0xFF));                       /* Write D0..D7                 */
00123   LCD_CS(1)
00124 }
00125 
00126 
00127 /*******************************************************************************
00128 * Start of data writing to LCD controller                                      *
00129 *   Parameter:                                                                 *
00130 *   Return:                                                                    *
00131 *******************************************************************************/
00132 
00133 static __INLINE void wr_dat_start (void) {
00134 
00135   LCD_CS(0)
00136   spi_send(SPI_START | SPI_WR | SPI_DATA);    /* Write : RS = 1, RW = 0       */
00137 }
00138 
00139 
00140 /*******************************************************************************
00141 * Stop of data writing to LCD controller                                       *
00142 *   Parameter:                                                                 *
00143 *   Return:                                                                    *
00144 *******************************************************************************/
00145 
00146 static __INLINE void wr_dat_stop (void) {
00147 
00148   LCD_CS(1)
00149 }
00150 
00151 
00152 /*******************************************************************************
00153 * Data writing to LCD controller                                               *
00154 *   Parameter:    c:      data to be written                                   *
00155 *   Return:                                                                    *
00156 *******************************************************************************/
00157 
00158 static __INLINE void wr_dat_only (unsigned short c) {
00159 
00160   spi_send((c >>   8));                       /* Write D8..D15                */
00161   spi_send((c & 0xFF));                       /* Write D0..D7                 */
00162 }
00163 
00164 
00165 /*******************************************************************************
00166 * Read data from LCD controller                                                *
00167 *   Parameter:                                                                 *
00168 *   Return:               read data                                            *
00169 *******************************************************************************/
00170 
00171 static __INLINE unsigned short rd_dat (void) {
00172   unsigned short val = 0;
00173 
00174   LCD_CS(0)
00175   spi_send(SPI_START | SPI_RD | SPI_DATA);    /* Read: RS = 1, RW = 1         */
00176   spi_send(0);                                /* Dummy read                   */
00177   val   = spi_send(0);                        /* Read D8..D15                 */
00178   val <<= 8;
00179   val  |= spi_send(0);                        /* Read D0..D7                  */
00180   LCD_CS(1)
00181   return (val);
00182 }
00183 
00184 /*******************************************************************************
00185 * Write to LCD register                                                        *
00186 *   Parameter:    reg:    register to be read                                  *
00187 *                 val:    value to write to register                           *
00188 *******************************************************************************/
00189 
00190 static __INLINE void wr_reg (unsigned char reg, unsigned short val) {
00191 
00192   wr_cmd(reg);
00193   wr_dat(val);
00194 }
00195 
00196 
00197 /*******************************************************************************
00198 * Read from LCD register                                                       *
00199 *   Parameter:    reg:    register to be read                                  *
00200 *   Return:               value read from register                             *
00201 *******************************************************************************/
00202 
00203 static unsigned short rd_reg (unsigned char reg) {
00204 
00205   wr_cmd(reg);
00206   return (rd_dat());
00207 }
00208 
00209 
00210 /************************ Exported functions **********************************/
00211 
00212 /*******************************************************************************
00213 * Initialize the Graphic LCD controller                                        *
00214 *   Parameter:                                                                 *
00215 *   Return:                                                                    *
00216 *******************************************************************************/
00217 
00218 void GLCD_Init (void) {
00219   static unsigned short driverCode;
00220 
00221   /* Enable clock for SSP1, clock = CCLK / 2                                  */
00222   LPC_SC->PCONP       |= 0x00000400;
00223   LPC_SC->PCLKSEL0    |= 0x00200000;
00224 
00225   /* Configure the LCD Control pins                                           */
00226   LPC_PINCON->PINSEL9 &= 0xF0FFFFFF;
00227   LPC_GPIO4->FIODIR   |= 0x30000000;
00228   LPC_GPIO4->FIOSET    = 0x20000000;
00229 
00230   /* SSEL1 is GPIO output set to high                                         */
00231   LPC_GPIO0->FIODIR   |= 0x00000040;
00232   LPC_GPIO0->FIOSET    = 0x00000040;
00233   LPC_PINCON->PINSEL0 &= 0xFFF03FFF;
00234   LPC_PINCON->PINSEL0 |= 0x000A8000;
00235 
00236   /* Enable SPI in Master Mode, CPOL=1, CPHA=1                                */
00237   /* Max. 25 MBit used for Data Transfer @ 100MHz                              */
00238   LPC_SSP1->CR0        = 0xC7;
00239   LPC_SSP1->CPSR       = 0x02;
00240   LPC_SSP1->CR1        = 0x02;
00241 
00242   delay(5);                             /* Delay 50 ms                        */
00243   driverCode = rd_reg(0x00);
00244 
00245   /* Start Initial Sequence --------------------------------------------------*/
00246   wr_reg(0x01, 0x0100);                 /* Set SS bit                         */
00247   wr_reg(0x02, 0x0700);                 /* Set 1 line inversion               */
00248   wr_reg(0x04, 0x0000);                 /* Resize register                    */
00249   wr_reg(0x08, 0x0207);                 /* 2 lines front, 7 back porch        */
00250   wr_reg(0x09, 0x0000);                 /* Set non-disp area refresh cyc ISC  */
00251   wr_reg(0x0A, 0x0000);                 /* FMARK function                     */
00252   wr_reg(0x0C, 0x0000);                 /* RGB interface setting              */
00253   wr_reg(0x0D, 0x0000);                 /* Frame marker Position              */
00254   wr_reg(0x0F, 0x0000);                 /* RGB interface polarity             */
00255 
00256   /* Power On sequence -------------------------------------------------------*/
00257   wr_reg(0x10, 0x0000);                 /* Reset Power Control 1              */
00258   wr_reg(0x11, 0x0000);                 /* Reset Power Control 2              */
00259   wr_reg(0x12, 0x0000);                 /* Reset Power Control 3              */
00260   wr_reg(0x13, 0x0000);                 /* Reset Power Control 4              */
00261   delay(20);                            /* Discharge cap power voltage (200ms)*/
00262   wr_reg(0x10, 0x12B0);                 /* SAP, BT[3:0], AP, DSTB, SLP, STB   */
00263   wr_reg(0x11, 0x0007);                 /* DC1[2:0], DC0[2:0], VC[2:0]        */
00264   delay(5);                             /* Delay 50 ms                        */
00265   wr_reg(0x12, 0x01BD);                 /* VREG1OUT voltage                   */
00266   delay(5);                             /* Delay 50 ms                        */
00267   wr_reg(0x13, 0x1400);                 /* VDV[4:0] for VCOM amplitude        */
00268   wr_reg(0x29, 0x000E);                 /* VCM[4:0] for VCOMH                 */
00269   delay(5);                             /* Delay 50 ms                        */
00270   wr_reg(0x20, 0x0000);                 /* GRAM horizontal Address            */
00271   wr_reg(0x21, 0x0000);                 /* GRAM Vertical Address              */
00272 
00273   /* Adjust the Gamma Curve --------------------------------------------------*/
00274   if (driverCode == 0x5408) {           /* LCD with touch                     */
00275     wr_reg(0x30, 0x0B0D);
00276     wr_reg(0x31, 0x1923);
00277     wr_reg(0x32, 0x1C26);
00278     wr_reg(0x33, 0x261C);
00279     wr_reg(0x34, 0x2419);
00280     wr_reg(0x35, 0x0D0B);
00281     wr_reg(0x36, 0x1006);
00282     wr_reg(0x37, 0x0610);
00283     wr_reg(0x38, 0x0706);
00284     wr_reg(0x39, 0x0304);
00285     wr_reg(0x3A, 0x0E05);
00286     wr_reg(0x3B, 0x0E01);
00287     wr_reg(0x3C, 0x010E);
00288     wr_reg(0x3D, 0x050E);
00289     wr_reg(0x3E, 0x0403);
00290     wr_reg(0x3F, 0x0607);
00291   }
00292   if (driverCode == 0xC990) {           /* LCD without touch                  */
00293     wr_reg(0x30, 0x0006);
00294     wr_reg(0x31, 0x0101);
00295     wr_reg(0x32, 0x0003);
00296     wr_reg(0x35, 0x0106);
00297     wr_reg(0x36, 0x0B02);
00298     wr_reg(0x37, 0x0302);
00299     wr_reg(0x38, 0x0707);
00300     wr_reg(0x39, 0x0007);
00301     wr_reg(0x3C, 0x0600);
00302     wr_reg(0x3D, 0x020B);
00303   }
00304 
00305  /* Set GRAM area -----------------------------------------------------------*/
00306   wr_reg(0x50, 0x0000);                 /* Horizontal GRAM Start Address      */
00307   wr_reg(0x51, (HEIGHT-1));             /* Horizontal GRAM End   Address      */
00308   wr_reg(0x52, 0x0000);                 /* Vertical   GRAM Start Address      */
00309   wr_reg(0x53, (WIDTH-1));              /* Vertical   GRAM End   Address      */
00310   wr_reg(0x60, 0xA700);                 /* Gate Scan Line                     */
00311   if (driverCode == 0x5408)             /* LCD with touch                     */
00312     wr_reg(0x60, 0xA700);               /* Gate Scan Line                     */
00313   if (driverCode == 0xC990)             /* LCD without touch                  */
00314     wr_reg(0x60, 0x2700);               /* Gate Scan Line                     */
00315   wr_reg(0x61, 0x0001);                 /* NDL,VLE, REV                       */
00316   wr_reg(0x6A, 0x0000);                 /* Set scrolling line                 */
00317 
00318   /* Partial Display Control -------------------------------------------------*/
00319   wr_reg(0x80, 0x0000);
00320   wr_reg(0x81, 0x0000);
00321   wr_reg(0x82, 0x0000);
00322   wr_reg(0x83, 0x0000);
00323   wr_reg(0x84, 0x0000);
00324   wr_reg(0x85, 0x0000);
00325 
00326   /* Panel Control -----------------------------------------------------------*/
00327   wr_reg(0x90, 0x0010);
00328   wr_reg(0x92, 0x0000);
00329   wr_reg(0x93, 0x0003);
00330   wr_reg(0x95, 0x0110);
00331   wr_reg(0x97, 0x0000);
00332   wr_reg(0x98, 0x0000);
00333 
00334   /* Set GRAM write direction
00335      I/D=10 (Horizontal : increment, Vertical : increment)
00336      AM=1   (address is updated in vertical writing direction)                */
00337   wr_reg(0x03, 0x1038);
00338 
00339   wr_reg(0x07, 0x0137);                 /* 262K color and display ON          */
00340   LPC_GPIO4->FIOSET = 0x10000000;
00341 }
00342 
00343 
00344 /*******************************************************************************
00345 * Set draw window region to whole screen                                       *
00346 *   Parameter:                                                                 *
00347 *   Return:                                                                    *
00348 *******************************************************************************/
00349 
00350 void GLCD_WindowMax (void) {
00351 
00352   wr_reg(0x50, 0);                      /* Horizontal GRAM Start Address      */
00353   wr_reg(0x51, HEIGHT-1);               /* Horizontal GRAM End   Address (-1) */
00354   wr_reg(0x52, 0);                      /* Vertical   GRAM Start Address      */
00355   wr_reg(0x53, WIDTH-1);                /* Vertical   GRAM End   Address (-1) */
00356 }
00357 
00358 
00359 /*******************************************************************************
00360 * Draw a pixel in foreground color                                             *
00361 *   Parameter:      x:        horizontal position                              *
00362 *                   y:        vertical position                                *
00363 *   Return:                                                                    *
00364 *******************************************************************************/
00365 
00366 void GLCD_PutPixel (unsigned int x, unsigned int y) {
00367 
00368   wr_reg(0x20, y);
00369   wr_reg(0x21, WIDTH-1-x);
00370   wr_cmd(0x22);
00371   wr_dat(TextColor);
00372 }
00373 
00374 
00375 /*******************************************************************************
00376 * Set foreground color                                                         *
00377 *   Parameter:      color:    foreground color                                 *
00378 *   Return:                                                                    *
00379 *******************************************************************************/
00380 
00381 void GLCD_SetTextColor (unsigned short color) {
00382 
00383   TextColor = color;
00384 }
00385 
00386 
00387 /*******************************************************************************
00388 * Set background color                                                         *
00389 *   Parameter:      color:    background color                                 *
00390 *   Return:                                                                    *
00391 *******************************************************************************/
00392 
00393 void GLCD_SetBackColor (unsigned short color) {
00394 
00395   BackColor = color;
00396 }
00397 
00398 
00399 /*******************************************************************************
00400 * Clear display                                                                *
00401 *   Parameter:      color:    display clearing color                           *
00402 *   Return:                                                                    *
00403 *******************************************************************************/
00404 
00405 void GLCD_Clear (unsigned short color) {
00406   unsigned int   i;
00407 
00408   GLCD_WindowMax();
00409 
00410   wr_reg(0x20, 0);
00411   wr_reg(0x21, 0);
00412   wr_cmd(0x22);
00413   wr_dat_start();
00414   for(i = 0; i < (WIDTH*HEIGHT); i++)
00415     wr_dat_only(color);
00416   wr_dat_stop();
00417 }
00418 
00419 
00420 /*******************************************************************************
00421 * Draw character on given position                                             *
00422 *   Parameter:      x:        horizontal position                              *
00423 *                   y:        vertical position                                *
00424 *                   c:        pointer to character bitmap                      *
00425 *   Return:                                                                    *
00426 *******************************************************************************/
00427 
00428 void GLCD_DrawChar (unsigned int x, unsigned int y, unsigned short *c) {
00429   int idx = 0, i, j;
00430 
00431   x = WIDTH-x-CHAR_W;
00432   wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
00433   wr_reg(0x51, y+CHAR_H-1);             /* Horizontal GRAM End   Address (-1) */
00434   wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
00435   wr_reg(0x53, x+CHAR_W-1);             /* Vertical   GRAM End   Address (-1) */
00436 
00437   wr_reg(0x20, y);
00438   wr_reg(0x21, x);
00439   wr_cmd(0x22);
00440   wr_dat_start();
00441   for (j = 0; j < CHAR_H; j++) {
00442     for (i = CHAR_W-1; i >= 0; i--) {
00443       if((c[idx] & (1 << i)) == 0x00) {
00444         wr_dat_only(BackColor);
00445       } else {
00446         wr_dat_only(TextColor);
00447       }
00448     }
00449     c++;
00450   }
00451   wr_dat_stop();
00452 }
00453 
00454 
00455 /*******************************************************************************
00456 * Disply character on given line                                               *
00457 *   Parameter:      ln:       line number                                      *
00458 *                   col:      column number                                    *
00459 *                   c:        ascii character                                  *
00460 *   Return:                                                                    *
00461 *******************************************************************************/
00462 
00463 void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char c) {
00464 
00465   c -= 32;
00466   GLCD_DrawChar(col * CHAR_W, ln * CHAR_H, (unsigned short *)&Font_24x16[c * CHAR_H]);
00467 }
00468 
00469 
00470 /*******************************************************************************
00471 * Disply string on given line                                                  *
00472 *   Parameter:      ln:       line number                                      *
00473 *                   col:      column number                                    *
00474 *                   s:        pointer to string                                *
00475 *   Return:                                                                    *
00476 *******************************************************************************/
00477 
00478 void GLCD_DisplayString (unsigned int ln, unsigned int col, unsigned char *s) {
00479 
00480   GLCD_WindowMax();
00481   while (*s) {
00482     GLCD_DisplayChar(ln, col++, *s++);
00483   }
00484 }
00485 
00486 
00487 /*******************************************************************************
00488 * Clear given line                                                             *
00489 *   Parameter:      ln:       line number                                      *
00490 *   Return:                                                                    *
00491 *******************************************************************************/
00492 
00493 void GLCD_ClearLn (unsigned int ln) {
00494 
00495   GLCD_WindowMax();
00496   GLCD_DisplayString(ln, 0, "                    ");
00497 }
00498 
00499 /*******************************************************************************
00500 * Draw bargraph                                                                *
00501 *   Parameter:      x:        horizontal position                              *
00502 *                   y:        vertical position                                *
00503 *                   w:        maximum width of bargraph (in pixels)            *
00504 *                   val:      value of active bargraph (in 1/1024)             *
00505 *   Return:                                                                    *
00506 *******************************************************************************/
00507 
00508 void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) {
00509   int i,j;
00510 
00511   x = WIDTH-x-w;
00512   wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
00513   wr_reg(0x51, y+CHAR_H-1);             /* Horizontal GRAM End   Address (-1) */
00514   wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
00515   wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
00516 
00517   val = (val * w) >> 10;                /* Scale value for 24x12 characters   */
00518   wr_reg(0x20, y);
00519   wr_reg(0x21, x);
00520   wr_cmd(0x22);
00521   wr_dat_start();
00522   for (i = 0; i < h; i++) {
00523     for (j = w-1; j >= 0; j--) {
00524       if(j >= val) {
00525         wr_dat_only(BackColor);
00526       } else {
00527         wr_dat_only(TextColor);
00528       }
00529     }
00530   }
00531   wr_dat_stop();
00532 }
00533 
00534 
00535 /*******************************************************************************
00536 * Display graphical bitmap image at position x horizontally and y vertically   *
00537 * (This function is optimized for 16 bits per pixel format, it has to be       *
00538 *  adapted for any other bits per pixel format)                                *
00539 *   Parameter:      x:        horizontal position                              *
00540 *                   y:        vertical position                                *
00541 *                   w:        width of bitmap                                  *
00542 *                   h:        height of bitmap                                 *
00543 *                   bitmap:   address at which the bitmap data resides         *
00544 *   Return:                                                                    *
00545 *******************************************************************************/
00546 
00547 void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) {
00548   unsigned int    i, j;
00549   unsigned short *bitmap_ptr = (unsigned short *)bitmap;
00550 
00551   x = WIDTH-x-w;
00552   wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
00553   wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
00554   wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
00555   wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
00556 
00557   wr_reg(0x20, y);
00558   wr_reg(0x21, x);
00559   wr_cmd(0x22);
00560   wr_dat_start();
00561   for (j = 0; j < h; j++) {
00562     bitmap_ptr += w-1;
00563     for (i = 0; i < w; i++) {
00564       wr_dat_only(*bitmap_ptr--);
00565     }
00566     bitmap_ptr += w+1;
00567   }
00568   wr_dat_stop();
00569 }
00570 
00571 
00572 /*******************************************************************************
00573 * Display graphical bmp file image at position x horizontally and y vertically *
00574 * (This function is optimized for 16 bits per pixel format, it has to be       *
00575 *  adapted for any other bits per pixel format)                                *
00576 *   Parameter:      x:        horizontal position                              *
00577 *                   y:        vertical position                                *
00578 *                   w:        width of bitmap                                  *
00579 *                   h:        height of bitmap                                 *
00580 *                   bmp:      address at which the bmp data resides            *
00581 *   Return:                                                                    *
00582 *******************************************************************************/
00583 
00584 void GLCD_Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp) {
00585   unsigned int    i, j;
00586   unsigned short *bitmap_ptr = (unsigned short *)bmp;
00587 
00588   x = WIDTH-x-w;
00589   wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
00590   wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
00591   wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
00592   wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
00593 
00594   wr_reg(0x20, y);
00595   wr_reg(0x21, x);
00596   wr_cmd(0x22);
00597   wr_dat_start();
00598   bitmap_ptr += (h*w)-1;
00599   for (j = 0; j < h; j++) {
00600     for (i = 0; i < w; i++) {
00601       wr_dat_only(*bitmap_ptr--);
00602     }
00603   }
00604   wr_dat_stop();
00605 }
00606 
00607 /******************************************************************************/