SAM3S8/SD8 Software Package: libraries/sam-gui/source/disp/backends/ILI9325/backend_ILI9325.c Source File

SAM3S8/SD8 Software Package 1.2

# backend_ILI9325.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2009, Atmel Corporation
    00005  *
    00006  * All rights reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions are met:
    00010  *
    00011  * - Redistributions of source code must retain the above copyright notice,
    00012  * this list of conditions and the disclaimer below.
    00013  *
    00014  * Atmel's name may not be used to endorse or promote products derived from
    00015  * this software without specific prior written permission.
    00016  *
    00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
    00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
    00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  * ----------------------------------------------------------------------------
    00028  */
    00029
    00030 /**
    00031  * \file
    00032  * \section Purpose
    00033  *   Implementation of ILI9325 driver.
    00034  *
    00035  * \section Usage
    00036  * The ILI9325 LCD Controller can be accessed through the \ref SDISPBackend DISP Backend interface
    00037  */
    00038
    00039 /*----------------------------------------------------------------------------
    00040  *        Headers
    00041  *----------------------------------------------------------------------------*/
    00042 #include "board.h"
    00043 #include "libsam_gui.h"
    00044
    00045 #include <stdio.h>
    00046
    00047 /*----------------------------------------------------------------------------
    00048  *        Types
    00049  *----------------------------------------------------------------------------*/
    00050
    00051 #ifdef __ICCARM__          // IAR
    00052 #pragma pack(1)            // IAR
    00053 #define __attribute__(...) // IAR
    00054 #endif                     // IAR
    00055
    00056 // BMP (Windows) Header Format
    00057 struct _SBMPHeader
    00058 {
    00059     uint16_t wType ; // signature, must be 4D42 hex
    00060     uint32_t dwFileSize ; // size of BMP file in bytes (unreliable)
    00061     uint16_t wReserved1 ; // reserved, must be zero
    00062     uint16_t wReserved2 ; // reserved, must be zero
    00063     uint32_t dwOffset ; // offset to start of image data in bytes
    00064     uint32_t dwHeaderSize ; // size of BITMAPINFOHEADER structure, must be 40
    00065     uint32_t dwWidth ; // image width in pixels
    00066     uint32_t dwHeight ; // image height in pixels
    00067     uint16_t wPlanes ; // number of planes in the image, must be 1
    00068     uint16_t wBits ; // number of bits per pixel (1, 4, 8, 16, 24, 32)
    00069     uint32_t dwCompression ; // compression type (0=none, 1=RLE-8, 2=RLE-4)
    00070     uint32_t dwImageSize ; // size of image data in bytes (including padding)
    00071     uint32_t dwHResolution ; // horizontal resolution in pixels per meter (unreliable)
    00072     uint32_t dwVResolution ; // vertical resolution in pixels per meter (unreliable)
    00073     uint32_t dwColours ; // number of colors in image, or zero
    00074     uint32_t dwImportantcolours ; // number of important colors, or zero
    00075 } __attribute__ ((packed)); // GCC
    00076
    00077 #ifdef __ICCARM__          // IAR
    00078 #pragma pack()             // IAR
    00079 #endif                     // IAR
    00080
    00081 typedef struct _SBMPHeader SBMPHeader ;
    00082
    00083 typedef volatile uint8_t vByte ;
    00084
    00085 /*----------------------------------------------------------------------------
    00086  *        Macros
    00087  *----------------------------------------------------------------------------*/
    00088
    00089 /** LCD index register address */
    00090 #define ILI9325_IR (*((vByte *)(BOARD_LCD_BASE)))
    00091 /** LCD status register address */
    00092 #define ILI9325_SR (*((vByte *)(BOARD_LCD_BASE)))
    00093 /** LCD data address */
    00094 #define ILI9325_D  (*((vByte *)((uint32_t)(BOARD_LCD_BASE) + BOARD_LCD_RS)))
    00095
    00096 #define ILI9325_WIDTH        240
    00097 #define ILI9325_HEIGTH       320
    00098
    00099 //#define ILI9325_BGR_MODE
    00100 #define ILI9325_RGB_MODE
    00101
    00102 /*----------------------------------------------------------------------------
    00103  *        Definitions
    00104  *----------------------------------------------------------------------------*/
    00105
    00106 /* ILI9325 ID code */
    00107 #define ILI9325_DEVICE_CODE    0x9325
    00108
    00109 /* ILI9325 LCD Registers */
    00110 #define TS_INS_START_OSC            0x00 /* Driver Code Read - data read at this instruction should be 0x0789 */
    00111 #define TS_INS_DRIV_OUT_CTRL        0x01 /* Driver Output Control 1          */
    00112 #define TS_INS_DRIV_WAV_CTRL        0x02 /* LCD Driving Control              */
    00113 #define TS_INS_ENTRY_MOD            0x03 /* Entry Mode                       */
    00114 #define TS_INS_RESIZE_CTRL          0x04 /* Resize Control                   */
    00115
    00116 #define TS_INS_DISP_CTRL1           0x07 /* Display Control 1                */
    00117 #define TS_INS_DISP_CTRL2           0x08 /* Display Control 2                */
    00118 #define TS_INS_DISP_CTRL3           0x09 /* Display Control 3                */
    00119 #define TS_INS_DISP_CTRL4           0x0A /* Display Control 4                */
    00120
    00121 #define TS_INS_RGB_DISP_IF_CTRL1    0x0C /* RGB Display Interface Control 1  */
    00122 #define TS_INS_FRM_MARKER_POS       0x0D /* Frame Maker Position             */
    00123 #define TS_INS_RGB_DISP_IF_CTRL2    0x0F /* RGB Display Interface Control 2  */
    00124
    00125 #define TS_INS_POW_CTRL1            0x10 /* Power Control 1 */
    00126 #define TS_INS_POW_CTRL2            0x11 /* Power Control 2 */
    00127 #define TS_INS_POW_CTRL3            0x12 /* Power Control 3 */
    00128 #define TS_INS_POW_CTRL4            0x13 /* Power Control 4 */
    00129
    00130 #define TS_INS_GRAM_HOR_AD          0x20 /* Horizontal GRAM Address Set  */
    00131 #define TS_INS_GRAM_VER_AD          0x21 /* Vertical  GRAM Address Set   */
    00132 #define TS_INS_RW_GRAM              0x22 /* Write Data to GRAM           */
    00133 #define TS_INS_POW_CTRL7            0x29 /* Power Control 7              */
    00134 #define TS_INS_FRM_RATE_COL_CTRL    0x2B /* Frame Rate and Color Control */
    00135
    00136 #define TS_INS_GAMMA_CTRL1          0x30 /* Gamma Control 1  */
    00137 #define TS_INS_GAMMA_CTRL2          0x31 /* Gamma Control 2  */
    00138 #define TS_INS_GAMMA_CTRL3          0x32 /* Gamma Control 3  */
    00139 #define TS_INS_GAMMA_CTRL4          0x35 /* Gamma Control 4  */
    00140 #define TS_INS_GAMMA_CTRL5          0x36 /* Gamma Control 5  */
    00141 #define TS_INS_GAMMA_CTRL6          0x37 /* Gamma Control 6  */
    00142 #define TS_INS_GAMMA_CTRL7          0x38 /* Gamma Control 7  */
    00143 #define TS_INS_GAMMA_CTRL8          0x39 /* Gamma Control 8  */
    00144 #define TS_INS_GAMMA_CTRL9          0x3C /* Gamma Control 9  */
    00145 #define TS_INS_GAMMA_CTRL10         0x3D /* Gamma Control 10 */
    00146
    00147 #define TS_INS_HOR_START_AD         0x50 /* Horizontal Address Start Position */
    00148 #define TS_INS_HOR_END_AD           0x51 /* Horizontal Address End Position   */
    00149 #define TS_INS_VER_START_AD         0x52 /* Vertical Address Start Position   */
    00150 #define TS_INS_VER_END_AD           0x53 /* Vertical Address End Position     */
    00151
    00152 #define TS_INS_GATE_SCAN_CTRL1      0x60 /* Driver Output Control 2    */
    00153 #define TS_INS_GATE_SCAN_CTRL2      0x61 /* Base Image Display Control */
    00154 #define TS_INS_GATE_SCAN_CTRL3      0x6A /* Vertical Scroll Control    */
    00155
    00156 #define TS_INS_PART_IMG1_DISP_POS   0x80 /* Partial Image 1 Display Position  */
    00157 #define TS_INS_PART_IMG1_START_AD   0x81 /* Partial Image 1 Area (Start Line) */
    00158 #define TS_INS_PART_IMG1_END_AD     0x82 /* Partial Image 1 Area (End Line)   */
    00159 #define TS_INS_PART_IMG2_DISP_POS   0x83 /* Partial Image 2 Display Position  */
    00160 #define TS_INS_PART_IMG2_START_AD   0x84 /* Partial Image 2 Area (Start Line) */
    00161 #define TS_INS_PART_IMG2_END_AD     0x85 /* Partial Image 2 Area (End Line)   */
    00162
    00163 #define TS_INS_PANEL_IF_CTRL1       0x90 /* Panel Interface Control 1 */
    00164 #define TS_INS_PANEL_IF_CTRL2       0x92 /* Panel Interface Control 2 */
    00165 #define TS_INS_PANEL_IF_CTRL3       0x93
    00166 #define TS_INS_PANEL_IF_CTRL4       0x95 /* Panel Interface Control 4 */
    00167 #define TS_INS_PANEL_IF_CTRL5       0x97
    00168 #define TS_INS_PANEL_IF_CTRL6       0x98
    00169
    00170 #define TS_INS_PANEL_IF_OTP_PC      0xA1    /* OTP VCM Programming Control */
    00171 #define TS_INS_PANEL_IF_OTP_STATUS  0xA2    /* OTP VCM Status and Enable   */
    00172 #define TS_INS_PANEL_IF_OTP_KEY     0xA5    /* OTP Programming ID Key      */
    00173
    00174 //touch screen LCD configuration
    00175 #define TS_ORN_PORTRAIT
    00176
    00177 #ifdef TS_ORN_PORTRAIT
    00178 #    define TS_SIZE_X                   240
    00179 #    define TS_SIZE_Y                   320
    00180 #    define TS_VAL_ENTRY_MOD            0x0030
    00181 #    define TS_INS_GRAM_ADX             TS_INS_GRAM_HOR_AD
    00182 #    define TS_INS_GRAM_ADY             TS_INS_GRAM_VER_AD
    00183 #    define TS_INS_START_ADX            TS_INS_HOR_START_AD
    00184 #    define TS_INS_END_ADX              TS_INS_HOR_END_AD
    00185 #    define TS_INS_START_ADY            TS_INS_VER_START_AD
    00186 #    define TS_INS_END_ADY              TS_INS_VER_END_AD
    00187 #else
    00188 #    define TS_SIZE_X                   320
    00189 #    define TS_SIZE_Y                   240
    00190 #    define TS_VAL_ENTRY_MOD            0x0028
    00191 #    define TS_INS_GRAM_ADX             TS_INS_GRAM_VER_AD
    00192 #    define TS_INS_GRAM_ADY             TS_INS_GRAM_HOR_AD
    00193 #    define TS_INS_START_ADX            TS_INS_VER_START_AD
    00194 #    define TS_INS_END_ADX              TS_INS_VER_END_AD
    00195 #    define TS_INS_START_ADY            TS_INS_HOR_START_AD
    00196 #    define TS_INS_END_ADY              TS_INS_HOR_END_AD
    00197 #endif
    00198
    00199 /*----------------------------------------------------------------------------
    00200  *        Statics
    00201  *----------------------------------------------------------------------------*/
    00202
    00203 /** static buffer for file operations */
    00204 static uint8_t _DBE_ILI9325_aucFileData[1024*2] ;
    00205
    00206 /**
    00207  * \brief Write data to LCD Register.
    00208  *
    00209  * \param ucReg   Register address.
    00210  * \param wData  Data to be written.
    00211  */
    00212 static void _DBE_ILI9325_WriteReg( uint8_t ucReg, uint16_t wData )
    00213 {
    00214     ILI9325_IR = 0 ;
    00215     ILI9325_IR = ucReg ;
    00216     ILI9325_D  = (wData >> 8) & 0xFF ;
    00217     ILI9325_D  = wData & 0xFF ;
    00218 }
    00219
    00220 /**
    00221  * \brief Read data from LCD Register.
    00222  *
    00223  * \param ucReg   Register address.
    00224  *
    00225  * \return      Readed data.
    00226  */
    00227 static uint16_t _DBE_ILI9325_ReadReg( uint8_t ucReg )
    00228 {
    00229     uint16_t wValue ;
    00230
    00231     ILI9325_IR = 0 ;
    00232     ILI9325_IR = ucReg ;
    00233
    00234     wValue = ILI9325_D ;
    00235     wValue = (wValue << 8) | ILI9325_D ;
    00236
    00237     return wValue ;
    00238 }
    00239
    00240 /**
    00241  * \brief Read LCD status Register.
    00242  *
    00243  * \return status data.
    00244  */
    00245 static uint16_t _DBE_ILI9325_ReadStatus( void )
    00246 {
    00247     return ILI9325_SR ;
    00248 }
    00249
    00250 /**
    00251  * \brief Prepare to access GRAM data.
    00252  */
    00253 static inline void _DBE_ILI9325_RAMAccess_Prepare( void )
    00254 {
    00255     ILI9325_IR=0 ;
    00256     ILI9325_IR=TS_INS_RW_GRAM ;
    00257 }
    00258
    00259 /**
    00260  * \brief Write data to LCD GRAM.
    00261  *
    00262  * \param dwColor  24-bits RGB color.
    00263  */
    00264 static void _DBE_ILI9325_WriteRAM( uint32_t dwColor )
    00265 {
    00266 #ifdef ILI9325_BGR_MODE
    00267     ILI9325_D = (dwColor & 0xff) ;
    00268     ILI9325_D = ((dwColor >> 8) & 0xff) ;
    00269     ILI9325_D = ((dwColor >> 16) & 0xff) ;
    00270 #endif // ILI9325_BGR_MODE
    00271
    00272 #ifdef ILI9325_RGB_MODE
    00273     ILI9325_D = ((dwColor >> 16) & 0xff) ;
    00274     ILI9325_D = ((dwColor >> 8) & 0xff) ;
    00275     ILI9325_D = (dwColor & 0xff) ;
    00276 #endif // ILI9325_RGB_MODE
    00277 }
    00278
    00279 /**
    00280  * \brief Read data to LCD GRAM.
    00281  *
    00282  * \note Because pixel data LCD GRAM is 18-bits, so conversion to RGB 24-bits
    00283  * will cause low color bit lose.
    00284  *
    00285  * \return SAMGUI_E_OK.
    00286  */
    00287 static uint32_t _DBE_ILI9325_ReadRAM( SGUIColor* pclrResult )
    00288 {
    00289     uint8_t ucValue ;
    00290
    00291     ucValue=ILI9325_D ; // dummy read
    00292     ucValue=ILI9325_D ; // dummy read
    00293     ucValue=ILI9325_D ; // data upper byte
    00294     pclrResult->u.RGBA.ucR=ucValue & 0xf8 ;
    00295     pclrResult->u.RGBA.ucG=(ucValue & 0x07) << 13 ;
    00296
    00297     ucValue=ILI9325_D ; // data lower byte
    00298     pclrResult->u.RGBA.ucG|=(ucValue & 0xe0) << 5 ;
    00299     pclrResult->u.RGBA.ucB=(ucValue & 0x1f) << 19 ;
    00300
    00301     return SAMGUI_E_OK ;
    00302 }
    00303
    00304 /**
    00305  * \brief Set cursor of LCD srceen.
    00306  *
    00307  * \param wX  X-coordinate of cursor.
    00308  * \param wY  Y-coordinate of cursor.
    00309  */
    00310 static inline void _DBE_ILI9325_SetCursor( uint16_t wX, uint16_t wY )
    00311 {
    00312     _DBE_ILI9325_WriteReg( TS_INS_GRAM_HOR_AD, wX ) ; // column
    00313     _DBE_ILI9325_WriteReg( TS_INS_GRAM_VER_AD, wY ) ; // row
    00314 }
    00315
    00316 /**
    00317  * \brief Turn on the LCD.
    00318  */
    00319 static inline void _DBE_ILI9325_LCD_On( void )
    00320 {
    00321     _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x133 ) ;
    00322 }
    00323
    00324 /**
    00325  * \brief Turn off the LCD.
    00326  */
    00327 static inline void _DBE_ILI9325_LCD_Off( void )
    00328 {
    00329     _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x00 ) ;
    00330 }
    00331
    00332 static uint32_t _DBE_ILI9325_Reset( void )
    00333 {
    00334     return SAMGUI_E_OK ;
    00335 }
    00336
    00337 /**
    00338  * \brief Set the backlight of the LCD.
    00339  *
    00340  * \param dwLevel Backlight brightness level [1..16], 1 means maximum brightness.
    00341  */
    00342 static void _DBE_ILI9325_SetBacklight( uint32_t dwLevel )
    00343 {
    00344     uint32_t i ;
    00345     const Pin pPins[]={ BOARD_BACKLIGHT_PIN } ;
    00346
    00347 //    printf( "_DBE_ILI9325_SetBacklight - %u\r\n", dwLevel ) ;
    00348
    00349     // Ensure valid level
    00350     if ( dwLevel < 1 )
    00351     {
    00352         dwLevel=1 ;
    00353     }
    00354     else
    00355     {
    00356         if ( dwLevel > 16 )
    00357         {
    00358             dwLevel=16 ;
    00359         }
    00360     }
    00361
    00362     // Switch off backlight
    00363     PIO_Clear( pPins ) ;
    00364     SAMGUI_TaskDelay( 2 ) ;
    00365
    00366     // Set new backlight level
    00367     for ( i=17 ; i > dwLevel ; i-- )
    00368     {
    00369         PIO_Clear( pPins ) ;
    00370         PIO_Clear( pPins ) ;
    00371         PIO_Clear( pPins ) ;
    00372
    00373         PIO_Set( pPins ) ;
    00374         PIO_Set( pPins ) ;
    00375         PIO_Set( pPins ) ;
    00376     }
    00377 }
    00378
    00379 static void _DBE_ILI9325_SetOrientation( uint32_t dwOrientation )
    00380 {
    00381 //DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT
    00382 //DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE
    00383 }
    00384
    00385 static inline void _DBE_ILI9325_SetBGRMode( void )
    00386 {
    00387     _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; /* set GRAM write direction and BGR=1. */
    00388 }
    00389
    00390 static inline void _DBE_ILI9325_SetRGBMode( void )
    00391 {
    00392     _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xd030 ) ; /* set GRAM write direction and BGR=1. */
    00393 }
    00394
    00395 static void _DBE_ILI9325_SetWindow( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight )
    00396 {
    00397     /* Set Horizontal Address Start Position */
    00398    _DBE_ILI9325_WriteReg( TS_INS_HOR_START_AD, (uint16_t)dwX ) ;
    00399
    00400    /* Set Horizontal Address End Position */
    00401    _DBE_ILI9325_WriteReg( TS_INS_HOR_END_AD, (uint16_t)dwX+dwWidth-1 ) ;
    00402
    00403    /* Set Vertical Address Start Position */
    00404    _DBE_ILI9325_WriteReg( TS_INS_VER_START_AD, (uint16_t)dwY ) ;
    00405
    00406    /* Set Vertical Address End Position */
    00407    _DBE_ILI9325_WriteReg( TS_INS_VER_END_AD, (uint16_t)dwY+dwHeight-1 ) ;
    00408 }
    00409
    00410 /**
    00411  * \brief Initialize the LCD controller.
    00412  */
    00413 static uint32_t _DBE_ILI9325_Initialize( void )
    00414 {
    00415     const Pin pPins[]={ BOARD_LCD_PINS, BOARD_BACKLIGHT_PIN } ;
    00416     Smc *pSmc=SMC ;
    00417     uint16_t wChipID ;
    00418
    00419     // Enable pins
    00420     PIO_Configure( pPins, PIO_LISTSIZE( pPins ) ) ;
    00421
    00422     // Enable peripheral clock
    00423     PMC_EnablePeripheral( ID_SMC ) ;
    00424
    00425     // EBI SMC Configuration
    00426     pSmc->SMC_CS_NUMBER[1].SMC_SETUP = 0
    00427                 | ((2 <<  0) & SMC_SETUP1_NWE_SETUP)
    00428                 | ((2 <<  8) & SMC_SETUP1_NCS_WR_SETUP)
    00429                 | ((2 << 16) & SMC_SETUP1_NRD_SETUP)
    00430                 | ((2 << 24) & SMC_SETUP1_NCS_RD_SETUP)
    00431                 ;
    00432
    00433     pSmc->SMC_CS_NUMBER[1].SMC_PULSE = 0
    00434                 | ((4  <<  0) & SMC_PULSE1_NWE_PULSE)
    00435                 | ((4  <<  8) & SMC_PULSE1_NCS_WR_PULSE)
    00436                 | ((10 << 16) & SMC_PULSE1_NRD_PULSE)
    00437                 | ((10 << 24) & SMC_PULSE1_NCS_RD_PULSE)
    00438                 ;
    00439
    00440     pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = 0
    00441                 | ((7 <<  0) & SMC_CYCLE1_NWE_CYCLE)
    00442                 | ((20 << 16) & SMC_CYCLE1_NRD_CYCLE)
    00443 //                | ((10 <<  0) & SMC_CYCLE1_NWE_CYCLE)
    00444 //                | ((22 << 16) & SMC_CYCLE1_NRD_CYCLE)
    00445                 ;
    00446
    00447     pSmc->SMC_CS_NUMBER[1].SMC_MODE = 0
    00448                 | (SMC_MODE1_READ_MODE)
    00449                 | (SMC_MODE1_WRITE_MODE)
    00450                 | (0) /* Set 8 bit width. TODO: replace with definition in device header file */
    00451                 ;
    00452
    00453     // Check ILI9325 chipid
    00454 //    wChipID=_DBE_ILI9325_ReadReg( TS_INS_START_OSC ) ;
    00455 //    if ( wChipID != ILI9325_DEVICE_CODE )
    00456 //    {
    00457 //        printf( "Read ILI9325 chip ID (%x) error, skip initialization.\r\n", wChipID ) ;
    00458 //        return SAMGUI_E_WRONG_COMPONENT ;
    00459 //    }
    00460
    00461     // Turn off LCD
    00462     _DBE_ILI9325_LCD_Off() ;
    00463
    00464     // Start initial sequence
    00465     _DBE_ILI9325_WriteReg( TS_INS_POW_CTRL1, 0x0000 ) ; /* DSTB = LP = STB = 0 */
    00466     _DBE_ILI9325_WriteReg( TS_INS_START_OSC, 0x0001 ) ; /* start internal OSC */
    00467     _DBE_ILI9325_WriteReg( TS_INS_DRIV_OUT_CTRL, 0x0100 ) ; /* set SS and SM bit */
    00468     _DBE_ILI9325_WriteReg( TS_INS_DRIV_WAV_CTRL, 0x0700 ) ; /* set 1 line inversion */
    00469 #ifdef ILI9325_BGR_MODE
    00470 //    _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc030 ) ; /* set GRAM write direction and BGR=1. */
    00471     _DBE_ILI9325_SetBGRMode() ;
    00472 #endif // ILI9325_BGR_MODE
    00473 #ifdef ILI9325_RGB_MODE
    00474 //    _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xD030 ) ; /* set GRAM write direction and BGR=1. */
    00475     _DBE_ILI9325_SetRGBMode() ;
    00476
    00477 #endif // ILI9325_RGB_MODE
    00478     _DBE_ILI9325_WriteReg( TS_INS_RESIZE_CTRL, 0x0000 ) ; /* Resize register */
    00479 //    wChipID=_DBE_ILI9325_ReadReg( TS_INS_DISP_CTRL1 ) ;
    00480 //    printf( "TS_INS_DISP_CTRL1 %x\r\n", wChipID ) ;
    00481 //    _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL1, 0x0100 ) ;
    00482     _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL2, 0x0207 ) ; /* set the back porch and front porch */
    00483     _DBE_ILI9325_WriteReg( TS_INS_DISP_CTRL3, 0x0000 ) ; /* set non-display area refresh cycle ISC[3:0] */
    00484     _DBE_ILI9325_WriteReg(TS_INS_DISP_CTRL4, 0x0000); /* FMARK function */
    00485     _DBE_ILI9325_WriteReg(TS_INS_RGB_DISP_IF_CTRL1, 0x0000); /* RGB interface setting */
    00486     _DBE_ILI9325_WriteReg(TS_INS_FRM_MARKER_POS, 0x0000); /* Frame marker Position */
    00487     _DBE_ILI9325_WriteReg(TS_INS_RGB_DISP_IF_CTRL2, 0x0000); /* RGB interface polarity */
    00488
    00489     /* Power on sequence */
    00490     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL1, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
    00491     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL2, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
    00492     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL3, 0x0000); /* VREG1OUT voltage */
    00493     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL4, 0x0000); /* VDV[4:0] for VCOM amplitude */
    00494
    00495     SAMGUI_TaskDelay( 200 ) ;           /* Dis-charge capacitor power voltage */
    00496
    00497     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL1, 0x1290); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
    00498     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL2, 0x0227); /* DC1[2:0], DC0[2:0], VC[2:0] */
    00499
    00500     SAMGUI_TaskDelay( 50 ) ;
    00501
    00502     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL3, 0x001B); /* Internal reference voltage= Vci; */
    00503
    00504     SAMGUI_TaskDelay( 50 ) ;
    00505
    00506     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL4, 0x1100); /* Set VDV[4:0] for VCOM amplitude */
    00507     _DBE_ILI9325_WriteReg(TS_INS_POW_CTRL7, 0x0019); /* Set VCM[5:0] for VCOMH */
    00508     _DBE_ILI9325_WriteReg(TS_INS_FRM_RATE_COL_CTRL, 0x000D); /* Set Frame Rate */
    00509
    00510     SAMGUI_TaskDelay( 50 ) ;
    00511
    00512     _DBE_ILI9325_SetCursor( 0, 0 ) ;
    00513
    00514     // Adjust the Gamma Curve
    00515     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL1, 0x0000);
    00516     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL2, 0x0204);
    00517     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL3, 0x0200);
    00518     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL4, 0x0007);
    00519     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL5, 0x1404);
    00520     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL6, 0x0705);
    00521     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL7, 0x0305);
    00522     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL8, 0x0707);
    00523     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL9, 0x0701);
    00524     _DBE_ILI9325_WriteReg(TS_INS_GAMMA_CTRL10, 0x000e);
    00525
    00526     // Set GRAM area (240x320)
    00527     _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    00528
    00529     _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL1, 0xa700);
    00530     _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL2, 0x0001);
    00531     _DBE_ILI9325_WriteReg(TS_INS_GATE_SCAN_CTRL3, 0x0000);
    00532
    00533     // Partial Display Control
    00534     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_DISP_POS, 0x0000);
    00535     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_START_AD, 0x0000);
    00536     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG1_END_AD, 0x0000);
    00537     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_DISP_POS, 0x0000);
    00538     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_START_AD, 0x0000);
    00539     _DBE_ILI9325_WriteReg(TS_INS_PART_IMG2_END_AD, 0x0000);
    00540
    00541     // Panel Control
    00542     _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL1, 0x0010);
    00543     _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL2, 0x0600);
    00544     _DBE_ILI9325_WriteReg(TS_INS_PANEL_IF_CTRL4, 0x0110);
    00545
    00546     return SAMGUI_E_OK ;
    00547 }
    00548
    00549 static uint32_t _DBE_ILI9325_Color666( uint32_t dwColor888 )
    00550 {
    00551     return ((dwColor888&0xfc)<<2)|((dwColor888&0xfc00)<<2)|((dwColor888&0xfc0000)<<2) ;
    00552 }
    00553
    00554 static uint32_t _DBE_ILI9325_GetPixel( uint32_t dwX, uint32_t dwY, SGUIColor* pclrResult )
    00555 {
    00556     if ( pclrResult == NULL )
    00557     {
    00558         return SAMGUI_E_BAD_POINTER ;
    00559     }
    00560
    00561     _DBE_ILI9325_SetCursor( dwX, dwY ) ;
    00562     _DBE_ILI9325_RAMAccess_Prepare() ;
    00563 //    pclrResult->u.dwRGBA=_DBE_ILI9325_ReadRAM() ;
    00564     _DBE_ILI9325_ReadRAM( pclrResult ) ;
    00565
    00566     return SAMGUI_E_OK ;
    00567 }
    00568
    00569 static uint32_t _DBE_ILI9325_DrawPixel( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn )
    00570 {
    00571     if ( dwX >= BOARD_LCD_WIDTH )
    00572     {
    00573         dwX=BOARD_LCD_WIDTH-1 ;
    00574     }
    00575
    00576     if ( dwY >= BOARD_LCD_HEIGHT )
    00577     {
    00578         dwY=BOARD_LCD_HEIGHT-1 ;
    00579     }
    00580
    00581     _DBE_ILI9325_SetCursor( dwX, dwY ) ;
    00582     _DBE_ILI9325_RAMAccess_Prepare() ;
    00583 #ifdef ILI9325_RGB_MODE
    00584     ILI9325_D=((pclrIn->u.dwRGBA >> 16) & 0xff) ;
    00585     ILI9325_D=((pclrIn->u.dwRGBA >> 8) & 0xff) ;
    00586     ILI9325_D=(pclrIn->u.dwRGBA & 0xff) ;
    00587 #endif // ILI9325_RGB_MODE
    00588
    00589 #ifdef ILI9325_BGR_MODE
    00590 //    _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ;
    00591     ILI9325_D=(pclrIn->u.dwRGBA & 0xff) ;
    00592     ILI9325_D=((pclrIn->u.dwRGBA >> 8) & 0xff) ;
    00593     ILI9325_D=((pclrIn->u.dwRGBA >> 16) & 0xff) ;
    00594 #endif // ILI9325_BGR_MODE
    00595
    00596     return SAMGUI_E_OK ;
    00597 }
    00598
    00599 static uint32_t _DBE_ILI9325_DrawLineBresenham( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn )
    00600 {
    00601     int dx, dy ;
    00602     int i ;
    00603     int xinc, yinc, cumul ;
    00604     int x, y ;
    00605
    00606     x = dwX1 ;
    00607     y = dwY1 ;
    00608     dx = dwX2 - dwX1 ;
    00609     dy = dwY2 - dwY1 ;
    00610
    00611     xinc = ( dx > 0 ) ? 1 : -1 ;
    00612     yinc = ( dy > 0 ) ? 1 : -1 ;
    00613     dx = ( dx > 0 ) ? dx : -dx ;
    00614     dy = ( dy > 0 ) ? dy : -dy ;
    00615
    00616     _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ;
    00617
    00618     if ( dx > dy )
    00619     {
    00620       cumul = dx / 2 ;
    00621       for ( i = 1 ; i <= dx ; i++ )
    00622       {
    00623         x += xinc ;
    00624         cumul += dy ;
    00625
    00626         if ( cumul >= dx )
    00627         {
    00628           cumul -= dx ;
    00629           y += yinc ;
    00630         }
    00631         _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ;
    00632       }
    00633     }
    00634     else
    00635     {
    00636         cumul = dy / 2 ;
    00637         for ( i = 1 ; i <= dy ; i++ )
    00638         {
    00639             y += yinc ;
    00640             cumul += dx ;
    00641
    00642             if ( cumul >= dy )
    00643             {
    00644                 cumul -= dy ;
    00645                 x += xinc ;
    00646             }
    00647
    00648             _DBE_ILI9325_DrawPixel( x, y, pclrIn ) ;
    00649         }
    00650     }
    00651
    00652     return SAMGUI_E_OK ;
    00653 }
    00654
    00655 static uint32_t _DBE_ILI9325_DrawLine( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn )
    00656 {
    00657     uint32_t dw=0 ;
    00658
    00659     if ( dwX1 >= BOARD_LCD_WIDTH )
    00660     {
    00661         dwX1=BOARD_LCD_WIDTH-1 ;
    00662     }
    00663
    00664     if ( dwX2 >= BOARD_LCD_WIDTH )
    00665     {
    00666         dwX2=BOARD_LCD_WIDTH-1 ;
    00667     }
    00668
    00669     if ( dwY1 >= BOARD_LCD_HEIGHT )
    00670     {
    00671         dwY1=BOARD_LCD_HEIGHT-1 ;
    00672     }
    00673
    00674     if ( dwY2 >= BOARD_LCD_HEIGHT )
    00675     {
    00676         dwY2=BOARD_LCD_HEIGHT-1 ;
    00677     }
    00678
    00679     _DBE_ILI9325_SetCursor( dwX1, dwY1 ) ;
    00680
    00681     // Horizontal line
    00682     if ( dwY1 == dwY2 )
    00683     {
    00684         _DBE_ILI9325_RAMAccess_Prepare() ;
    00685
    00686         if ( dwX1 > dwX2 )
    00687         {
    00688             dw=dwX1 ;
    00689             dwX1=dwX2 ;
    00690             dwX2=dw ;
    00691         }
    00692
    00693         for ( dw=dwX1 ; dw <= dwX2 ; dw++ )
    00694         {
    00695             _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ;
    00696         }
    00697     }
    00698     else
    00699     {
    00700         // Vertical line
    00701         if ( dwX1 == dwX2 )
    00702         {
    00703             if ( dwY1 > dwY2 )
    00704             {
    00705                 dw=dwY1 ;
    00706                 dwY1=dwY2 ;
    00707                 dwY2=dw ;
    00708             }
    00709
    00710             for ( dw=dwY1 ; dw <= dwY2 ; dw++ )
    00711             {
    00712                 _DBE_ILI9325_RAMAccess_Prepare() ;
    00713                 _DBE_ILI9325_WriteRAM( /*_DBE_ILI9325_Color666*/( pclrIn->u.dwRGBA ) ) ;
    00714                 _DBE_ILI9325_SetCursor( dwX1, dw ) ;
    00715             }
    00716         }
    00717         else // Bresenham
    00718         {
    00719             return _DBE_ILI9325_DrawLineBresenham( dwX1, dwY1, dwX2, dwY2, pclrIn ) ;
    00720         }
    00721     }
    00722
    00723     return SAMGUI_E_OK ;
    00724 }
    00725
    00726 #if 1
    00727 static uint32_t _DBE_ILI9325_DrawCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder )
    00728 {
    00729     signed int d ; // Decision Variable
    00730     uint32_t dwCurX ; // Current X Value
    00731     uint32_t dwCurY ; // Current Y Value
    00732
    00733     if ( pclrBorder == NULL )
    00734     {
    00735         return SAMGUI_E_BAD_POINTER ;
    00736     }
    00737
    00738     if ( dwRadius < 2 )
    00739     {
    00740         return SAMGUI_E_BAD_PARAMETER ;
    00741     }
    00742
    00743     d = 3 - (dwRadius << 1) ;
    00744     dwCurX = 0 ;
    00745     dwCurY = dwRadius ;
    00746
    00747     while ( dwCurX <= dwCurY )
    00748     {
    00749         _DBE_ILI9325_DrawPixel( dwX + dwCurX, dwY + dwCurY, pclrBorder ) ;
    00750         _DBE_ILI9325_DrawPixel( dwX + dwCurX, dwY - dwCurY, pclrBorder ) ;
    00751         _DBE_ILI9325_DrawPixel( dwX - dwCurX, dwY + dwCurY, pclrBorder ) ;
    00752         _DBE_ILI9325_DrawPixel( dwX - dwCurX, dwY - dwCurY, pclrBorder ) ;
    00753         _DBE_ILI9325_DrawPixel( dwX + dwCurY, dwY + dwCurX, pclrBorder ) ;
    00754         _DBE_ILI9325_DrawPixel( dwX + dwCurY, dwY - dwCurX, pclrBorder ) ;
    00755         _DBE_ILI9325_DrawPixel( dwX - dwCurY, dwY + dwCurX, pclrBorder ) ;
    00756         _DBE_ILI9325_DrawPixel( dwX - dwCurY, dwY - dwCurX, pclrBorder ) ;
    00757
    00758         if ( d < 0 )
    00759         {
    00760             d += (dwCurX << 2) + 6 ;
    00761         }
    00762         else
    00763         {
    00764             d += ((dwCurX - dwCurY) << 2) + 10;
    00765             dwCurY-- ;
    00766         }
    00767
    00768         dwCurX++ ;
    00769     }
    00770
    00771     return SAMGUI_E_OK ;
    00772 }
    00773 #else
    00774 static void _DBE_ILI9325_Plot4points( uint32_t dwX, uint32_t dwY, int iX, int iY, SGUIColor* pclrBorder )
    00775 {
    00776   _DBE_ILI9325_DrawPixel( dwX+iX, dwY+iY, pclrBorder ) ;
    00777   if ( iX != 0 ) _DBE_ILI9325_DrawPixel( dwX-iX, dwY+iY, pclrBorder ) ;
    00778   if ( iY != 0 ) _DBE_ILI9325_DrawPixel( dwX+iX, dwY-iY, pclrBorder ) ;
    00779   if ( iX != 0 && iY != 0 ) _DBE_ILI9325_DrawPixel( dwX-iX, dwY-iY, pclrBorder ) ;
    00780 }
    00781
    00782 static void _DBE_ILI9325_Plot8points( uint32_t dwX, uint32_t dwY, int x, int iY, SGUIColor* pclrBorder )
    00783 {
    00784   _DBE_ILI9325_Plot4points( dwX, dwY, iX, iY, pclrBorder ) ;
    00785   if ( iX != iY ) _DBE_ILI9325_Plot4points( dwX, dwY, iY, iX, pclrBorder ) ;
    00786 }
    00787
    00788 static uint32_t _DBE_ILI9325_DrawCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder )
    00789 {
    00790   int iError=-dwRadius ;
    00791   int iX=dwRadius ;
    00792   int iY=0 ;
    00793
    00794   while ( iX >= iY )
    00795   {
    00796     plot8points( dwX, dwY, iX, iY, pclrBorder ) ;
    00797
    00798     iError+=iY ;
    00799     ++iY ;
    00800     iError+=iY ;
    00801
    00802     if ( iError >= 0 )
    00803     {
    00804       --iX ;
    00805       iError-=iX ;
    00806       iError-=iX ;
    00807     }
    00808   }
    00809 }
    00810 #endif
    00811
    00812 static uint32_t _DBE_ILI9325_DrawFilledCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder, SGUIColor* pclrInside )
    00813 {
    00814     signed int d ; // Decision Variable
    00815     uint32_t dwCurX ; // Current X Value
    00816     uint32_t dwCurY ; // Current Y Value
    00817
    00818 //    if ( pclrBorder == NULL )
    00819 //    {
    00820 //        return SAMGUI_E_BAD_POINTER ;
    00821 //    }
    00822
    00823     if ( dwRadius < 2 )
    00824     {
    00825         return SAMGUI_E_BAD_PARAMETER ;
    00826     }
    00827
    00828     d = 3 - (dwRadius << 1) ;
    00829     dwCurX = 0 ;
    00830     dwCurY = dwRadius ;
    00831
    00832     while ( dwCurX <= dwCurY )
    00833     {
    00834         _DBE_ILI9325_DrawLine( dwX-dwCurX, dwY-dwCurY, dwX+dwCurX, dwY-dwCurY, pclrInside ) ;
    00835         _DBE_ILI9325_DrawLine( dwX-dwCurX, dwY+dwCurY, dwX+dwCurX, dwY+dwCurY, pclrInside ) ;
    00836         _DBE_ILI9325_DrawLine( dwX-dwCurY, dwY-dwCurX, dwX+dwCurY, dwY-dwCurX, pclrInside ) ;
    00837         _DBE_ILI9325_DrawLine( dwX-dwCurY, dwY+dwCurX, dwX+dwCurY, dwY+dwCurX, pclrInside ) ;
    00838
    00839         if ( d < 0 )
    00840         {
    00841             d += (dwCurX << 2) + 6 ;
    00842         }
    00843         else
    00844         {
    00845             d += ((dwCurX - dwCurY) << 2) + 10;
    00846             dwCurY-- ;
    00847         }
    00848
    00849         dwCurX++ ;
    00850     }
    00851
    00852     if ( pclrBorder != NULL )
    00853     {
    00854         _DBE_ILI9325_DrawCircle( dwX, dwY, dwRadius, pclrBorder ) ;
    00855     }
    00856
    00857     return SAMGUI_E_OK ;
    00858 }
    00859
    00860 static uint32_t _DBE_ILI9325_DrawRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame )
    00861 {
    00862     uint32_t dw ;
    00863
    00864     // Check coordonates
    00865     if ( dwX1 > dwX2 )
    00866     {
    00867         dw=dwX1 ;
    00868         dwX1=dwX2 ;
    00869         dwX2=dw ;
    00870     }
    00871
    00872     if ( dwY1 > dwY2 )
    00873     {
    00874         dw=dwY1 ;
    00875         dwY1=dwY2 ;
    00876         dwY2=dw ;
    00877     }
    00878
    00879     _DBE_ILI9325_DrawLine( dwX1, dwY1, dwX2, dwY1, pclrFrame ) ;
    00880     _DBE_ILI9325_DrawLine( dwX1, dwY2, dwX2, dwY2, pclrFrame ) ;
    00881
    00882     _DBE_ILI9325_DrawLine( dwX1, dwY1, dwX1, dwY2, pclrFrame ) ;
    00883     _DBE_ILI9325_DrawLine( dwX2, dwY1, dwX2, dwY2, pclrFrame ) ;
    00884
    00885     return SAMGUI_E_OK ;
    00886 }
    00887
    00888 static uint32_t _DBE_ILI9325_DrawFilledRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame, SGUIColor* pclrInside )
    00889 {
    00890     uint32_t dw ;
    00891     uint32_t dwLength ;
    00892
    00893     // Check coordonates
    00894     if ( dwX1 > dwX2 )
    00895     {
    00896         dw=dwX1 ;
    00897         dwX1=dwX2 ;
    00898         dwX2=dw ;
    00899     }
    00900
    00901     if ( dwY1 > dwY2 )
    00902     {
    00903         dw=dwY1 ;
    00904         dwY1=dwY2 ;
    00905         dwY2=dw ;
    00906     }
    00907
    00908     _DBE_ILI9325_SetCursor( dwX1, dwY1 ) ;
    00909     _DBE_ILI9325_SetWindow( dwX1, dwY1, dwX2-dwX1+1, dwY2-dwY1+1 ) ;
    00910     _DBE_ILI9325_RAMAccess_Prepare() ;
    00911
    00912     dwLength=(dwX2-dwX1+1)*(dwY2-dwY1+1) ;
    00913     for ( dw=0 ; dw < dwLength ; dw++ )
    00914     {
    00915 //            _DBE_ILI9325_WriteRAM( pclrInside->u.dwRGBA ) ;
    00916 #ifdef ILI9325_BGR_MODE
    00917         ILI9325_D=(pclrInside->u.dwRGBA & 0xff) ;
    00918         ILI9325_D=((pclrInside->u.dwRGBA >> 8) & 0xff) ;
    00919         ILI9325_D=((pclrInside->u.dwRGBA >> 16) & 0xff) ;
    00920 #endif // ILI9325_BGR_MODE
    00921
    00922 #ifdef ILI9325_RGB_MODE
    00923         ILI9325_D=((pclrInside->u.dwRGBA >> 16) & 0xff) ;
    00924         ILI9325_D=((pclrInside->u.dwRGBA >> 8) & 0xff) ;
    00925         ILI9325_D=(pclrInside->u.dwRGBA & 0xff) ;
    00926 #endif // ILI9325_RGB_MODE
    00927     }
    00928
    00929     _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    00930
    00931     return SAMGUI_E_OK ;
    00932 }
    00933
    00934 static uint32_t _DBE_ILI9325_DrawBitmapBMP( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData )
    00935 {
    00936     uint32_t dwRow ;
    00937     uint32_t dwCol ;
    00938     uint32_t dwMinWidth ;
    00939     uint32_t dwMinHeight ;
    00940     SBMPHeader* pHeader ;
    00941 #ifdef ILI9325_RGB_MODE
    00942     uint8_t ucR ;
    00943     uint8_t ucG ;
    00944     uint8_t ucB ;
    00945 #endif // ILI9325_RGB_MODE
    00946     uint8_t* pucImage ;
    00947     uint8_t* pucLine ;
    00948     uint32_t dwScanLineBits ;
    00949     uint32_t dwScanLineBytes ;
    00950     SGUIColor clr={ .u.dwRGBA=0xff0000 } ;
    00951
    00952     // Read header information
    00953     pHeader=(SBMPHeader*)pucData ;
    00954
    00955 //    printf( "_DBE_ILI9325_DrawBitmapBMP\n\r" ) ;
    00956
    00957     dwScanLineBits=pHeader->dwWidth*pHeader->wBits ;
    00958     dwScanLineBytes=((dwScanLineBits+31)/32)*4 ;
    00959
    00960     // Check that parameters match
    00961     if ( (pHeader->dwCompression != 0) || (pHeader->dwWidth != dwWidth) || (pHeader->dwHeight != dwHeight) )
    00962     {
    00963         printf( "BMP_Decode: File format not supported\n\r" ) ;
    00964         printf( " -> .compression = %u\n\r", pHeader->dwCompression ) ;
    00965         printf( " -> .width = %u %u\n\r", pHeader->dwWidth, dwWidth ) ;
    00966         printf( " -> .height = %u %u\n\r", pHeader->dwHeight, dwHeight ) ;
    00967         printf( " -> .bits = %u\n\r", pHeader->wBits ) ;
    00968         printf( " -> .scanline_bits = %u\n\r", dwScanLineBits ) ;
    00969         printf( " -> .scanline_bytes = %u\n\r", dwScanLineBytes ) ;
    00970
    00971         _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ;
    00972         clr.u.dwRGBA=0x000000 ;
    00973         _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ;
    00974         _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ;
    00975
    00976         return 2 ;
    00977     }
    00978
    00979     // Get image data
    00980     pucImage=pucData+pHeader->dwOffset ;
    00981     dwMinWidth=(dwWidth+dwX < ILI9325_WIDTH)?dwWidth:ILI9325_WIDTH ;
    00982     dwMinHeight=(dwHeight+dwY < ILI9325_HEIGTH)?dwHeight:ILI9325_HEIGTH ;
    00983
    00984     switch ( pHeader->wBits )
    00985     {
    00986         case 24:
    00987 //            _DBE_ILI9325_WriteReg(ILI9325_R03H, _DBE_ILI9325_ReadReg( ILI9325_R03H )~(1<<12) ); /* set GRAM write direction and BGR=1. */
    00988             _DBE_ILI9325_SetCursor( dwX, dwY ) ;
    00989             _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ;
    00990             _DBE_ILI9325_RAMAccess_Prepare() ;
    00991
    00992             // Send image data to ILI9325 (swapping red & blue)
    00993             for ( dwRow=0 ; dwRow < dwMinHeight ; dwRow++ )
    00994             {
    00995                 pucLine=pucImage+((dwHeight-dwRow-1)*dwScanLineBytes) ;
    00996 //                printf( "_DBE_ILI9325_DrawBitmapBMP - Line %u/%u\n\r", dwRow, ((dwHeight-dwRow-1)*(dwWidth*3)) ) ;
    00997
    00998                 for ( dwCol=0 ; dwCol < dwMinWidth ; dwCol++ )
    00999                 {
    01000     #ifdef ILI9325_BGR_MODE
    01001                     ILI9325_D=(*pucLine/*<<2*/)++ ;
    01002                     ILI9325_D=(*pucLine/*<<2*/)++ ;
    01003                     ILI9325_D=(*pucLine/*<<2*/)++ ;
    01004     #endif // ILI9325_BGR_MODE
    01005
    01006     #ifdef ILI9325_RGB_MODE
    01007                     ucB=*pucLine++ ;
    01008                     ucG=*pucLine++ ;
    01009                     ucR=*pucLine++ ;
    01010                     ILI9325_D=ucR/*<<2*/ ;
    01011                     ILI9325_D=ucG/*<<2*/ ;
    01012                     ILI9325_D=ucB/*<<2*/ ;
    01013     #endif // ILI9325_RGB_MODE
    01014                 }
    01015             }
    01016
    01017             _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    01018
    01019 //            _DBE_ILI9325_WriteReg(ILI9325_R03H, _DBE_ILI9325_ReadReg( ILI9325_R03H )|(1<<12) ); /* set GRAM write direction and BGR=1. */
    01020         break ;
    01021
    01022         case 8:
    01023 //            // Retrieve palette
    01024 //            struct BMPPaletteEntry palette[256];
    01025 //            memcpy(palette,
    01026 //                   (unsigned char *) ((unsigned int) file + sizeof(struct BMPHeader)),
    01027 //                   header->offset - sizeof(struct BMPHeader));
    01028 //
    01029             // Decode image (reversing row order)
    01030             // Send image data to ILI9325 (swapping red & blue)
    01031             for ( dwRow=0 ; dwRow < dwMinHeight ; dwRow++ )
    01032             {
    01033                 _DBE_ILI9325_SetCursor( dwX, dwY+dwRow ) ;
    01034                 _DBE_ILI9325_RAMAccess_Prepare() ;
    01035                 pucLine=pucImage+((dwHeight-dwRow-1)*dwWidth) ;
    01036 //                printf( "_DBE_ILI9325_DrawBitmapBMP - Line %u/%u/%u\n\r", dwRow, dwMinWidth, ((dwHeight-dwRow-1)*dwWidth) ) ;
    01037
    01038                 for ( dwCol=0 ; dwCol < dwMinWidth ; dwCol++ )
    01039                 {
    01040                     ILI9325_D=(*pucLine++)/*<<2*/ ;
    01041                     ILI9325_D=(*pucLine++)/*<<2*/ ;
    01042                     ILI9325_D=(*pucLine++)/*<<2*/ ;
    01043                 }
    01044             }
    01045         break ;
    01046
    01047         default:
    01048             printf( "BMP_Decode: Input resolution not supported\n\r" ) ;
    01049             printf( "header->bits 0x%X \n\r", pHeader->wBits ) ;
    01050
    01051             _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ;
    01052             clr.u.dwRGBA=0x000000 ;
    01053             _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ;
    01054             _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ;
    01055
    01056             return 4 ;
    01057 //        break ;
    01058     }
    01059
    01060     return SAMGUI_E_OK ;
    01061 }
    01062
    01063 static uint32_t _DBE_ILI9325_DrawBitmapBMPFile( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData )
    01064 {
    01065     uint32_t dwMin ;
    01066     FIL fp ;
    01067     SBMPHeader sHeader ;
    01068     uint32_t dwLineLength ;
    01069     uint32_t dwLength ;
    01070     uint32_t dwTemp ;
    01071     uint32_t dwIndex ;
    01072     uint32_t dw ;
    01073     uint8_t* pucLineData ;
    01074
    01075     // Read first 256 bytes to obtain header
    01076     if ( f_open( &fp, (const char*)pucData, FA_OPEN_EXISTING|FA_READ ) == FR_OK )
    01077     {
    01078         if ( f_read( &fp, &sHeader, sizeof( sHeader ), &dwLength ) == FR_OK )
    01079         {
    01080 //            printf( "read %c%c\r\n", (char)(sHeader.wType&0xff), (char)(sHeader.wType>>8) ) ;
    01081 //            printf( " -> .dwCompression = %u\n\r", sHeader.dwCompression ) ;
    01082 //            printf( " -> .dwWidth = %u\n\r", sHeader.dwWidth ) ;
    01083 //            printf( " -> .dwHeight = %u\n\r", sHeader.dwHeight ) ;
    01084 //            printf( " -> .wBits = %u\n\r", sHeader.wBits ) ;
    01085 //            printf( " -> .dwOffset %u\r\n", sHeader.dwOffset ) ;
    01086 //            printf( " -> .dwColours %u\r\n", sHeader.dwColours ) ;
    01087 //            printf( " -> .dw %u\r\n", sHeader.dwColours*4+54 ) ;
    01088
    01089             dwLineLength=(((sHeader.dwWidth*sHeader.wBits)+31)/32)*4 ;
    01090
    01091             switch ( sHeader.wBits )
    01092             {
    01093                 case 24:
    01094                     // if header is Windows BMP 24bpp, alloc line size bytes on HEAP
    01095                     // Move file pointer to begin of BMP data
    01096 //                    f_lseek( &fp, sHeader.dwOffset ) ;
    01097
    01098 //                    dwX2=dwX ;
    01099 //                    dwY+=sHeader.height ;
    01100
    01101                     /* set GRAM write direction and BGR=1. */
    01102                     _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc010 ) ;
    01103                     /* Set window */
    01104                     _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ;
    01105 //                _DBE_ILI9325_SetCursor( dwX, dwY ) ; //+dwHeight-1 ) ;
    01106                     _DBE_ILI9325_SetCursor( dwX, dwY+dwHeight-1 ) ;
    01107
    01108
    01109     ////                dwX2=_DBE_ILI9325_ReadReg( ILI9325_R03H ) ;
    01110     //////                dwX2|=(1<<5) ; // I/D1=1
    01111     ////                dwX2&=~(1<<3) ; // I/D1=0
    01112     //////                dwX2&=~(1<<3) ; // AM=0
    01113     //////                dwX2|=(1<<3) ; // AM=1
    01114     ////                _DBE_ILI9325_WriteReg( ILI9325_R03H, (uint16_t)dwX2 ) ;
    01115
    01116                     ILI9325_IR=0 ;
    01117                     ILI9325_IR=TS_INS_RW_GRAM ;
    01118
    01119                     // Read buffer and write it on backend
    01120                     dwIndex=0 ;
    01121                     do
    01122                     {
    01123                         if ( f_read( &fp, _DBE_ILI9325_aucFileData, sizeof( _DBE_ILI9325_aucFileData ), &dwLength ) == FR_OK )
    01124                         {
    01125 //                            printf( "Read %u bytes\r\n", dwLength ) ;
    01126                             // Get Min value from read length and buffer length
    01127 //                            dwMin=(dwLength < sizeof( _DBE_ILI9325_aucFileData ) )?dwLength:sizeof( _DBE_ILI9325_aucFileData ) ;
    01128
    01129 //                            printf( "writing %u bytes\r\n", dwMin ) ;
    01130                             // Draw whole buffer data to backend
    01131                             dwMin=dwWidth*3 ;
    01132                             if ( dwLineLength != dwMin )
    01133                             {
    01134                                 for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++, dwIndex++ )
    01135                                 {
    01136                                     if ( (dwIndex >= dwMin) && (dwIndex < dwLineLength) )
    01137                                     {
    01138                                     }
    01139                                     else
    01140                                     {
    01141                                         if ( dwIndex == dwLineLength )
    01142                                         {
    01143                                             dwIndex=0 ;
    01144                                         }
    01145                                         ILI9325_D=_DBE_ILI9325_aucFileData[dwTemp] ;
    01146                                     }
    01147                                 }
    01148                             }
    01149                             else
    01150                             {
    01151                                 for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++ )
    01152                                 {
    01153                                     ILI9325_D=_DBE_ILI9325_aucFileData[dwTemp] ;
    01154                                 }
    01155                             }
    01156                         }
    01157                     } while ( dwLength == sizeof( _DBE_ILI9325_aucFileData ) ) ;
    01158
    01159 #if defined ILI9325_RGB_MODE
    01160                     _DBE_ILI9325_SetRGBMode() ;
    01161 #endif // defined ILI9325_RGB_MODE
    01162 #if defined ILI9325_BGR_MODE
    01163                     _DBE_ILI9325_SetBGRMode() ;
    01164 #endif // defined ILI9325_BGR_MODE
    01165                     // Restore whole window
    01166                     _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    01167                 break ;
    01168
    01169                 case 8:
    01170                     // Move file pointer to begin of BMP data
    01171 //                    f_lseek( &fp, 54 ) ;
    01172
    01173                     // Get LUT
    01174                     if ( f_read( &fp, _DBE_ILI9325_aucFileData, sHeader.dwColours<<2, &dwLength ) == FR_OK )
    01175                     {
    01176 //                        printf( "Read %u bytes\r\n", dwLength ) ;
    01177                     }
    01178
    01179 //                    f_lseek( &fp, sHeader.dwOffset ) ;
    01180
    01181                     /* set GRAM write direction and BGR=1. */
    01182                     _DBE_ILI9325_WriteReg( TS_INS_ENTRY_MOD, 0xc010 ) ;
    01183                     /* Set window */
    01184                     _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ;
    01185                     /* Set cursor */
    01186                     _DBE_ILI9325_SetCursor( dwX, dwY+dwHeight-1 ) ;
    01187                     ILI9325_IR=0 ;
    01188                     ILI9325_IR=TS_INS_RW_GRAM ;
    01189
    01190                     // Read buffer and write it on backend
    01191                     dwIndex=0 ;
    01192                     pucLineData=_DBE_ILI9325_aucFileData+1024/*(sHeader.dwColours<<2)*/ ;
    01193                     do
    01194                     {
    01195                         if ( f_read( &fp, pucLineData, sizeof( _DBE_ILI9325_aucFileData )-1024/*sHeader.dwColours<<2*/, &dwLength ) == FR_OK )
    01196                         {
    01197                             // Draw whole buffer data to backend
    01198                             dwMin=dwWidth/**3*/ ;
    01199                             if ( dwLineLength != dwMin )
    01200                             {
    01201                                 for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++, dwIndex++ )
    01202                                 {
    01203                                     if ( (dwIndex >= dwMin) && (dwIndex < dwLineLength) )
    01204                                     {
    01205                                     }
    01206                                     else
    01207                                     {
    01208                                         if ( dwIndex == dwLineLength )
    01209                                         {
    01210                                             dwIndex=0 ;
    01211                                         }
    01212                                         /* Get value */
    01213                                         dw=pucLineData[dwTemp]<<2 ;
    01214                                         /* Draw pixel */
    01215                                         ILI9325_D=_DBE_ILI9325_aucFileData[dw] ;
    01216                                         ILI9325_D=_DBE_ILI9325_aucFileData[dw+1] ;
    01217                                         ILI9325_D=_DBE_ILI9325_aucFileData[dw+2] ;
    01218                                     }
    01219                                 }
    01220                             }
    01221                             else
    01222                             {
    01223                                 for ( dwTemp=0 ; dwTemp < dwLength ; dwTemp++ )
    01224                                 {
    01225                                     /* Get value */
    01226                                     dw=pucLineData[dwTemp]<<2 ;
    01227                                     /* Draw pixel */
    01228                                     ILI9325_D=_DBE_ILI9325_aucFileData[dw] ;
    01229                                     ILI9325_D=_DBE_ILI9325_aucFileData[dw+1] ;
    01230                                     ILI9325_D=_DBE_ILI9325_aucFileData[dw+2] ;
    01231                                 }
    01232                             }
    01233                         }
    01234                     } while ( dwLength == sizeof( _DBE_ILI9325_aucFileData )-1024/*(sHeader.dwColours<<2)*/ ) ;
    01235
    01236 #if defined ILI9325_RGB_MODE
    01237                     _DBE_ILI9325_SetRGBMode() ;
    01238 #endif // defined ILI9325_RGB_MODE
    01239 #if defined ILI9325_BGR_MODE
    01240                     _DBE_ILI9325_SetBGRMode() ;
    01241 #endif // defined ILI9325_BGR_MODE
    01242                     // Restore whole window
    01243                     _DBE_ILI9325_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    01244                 break ;
    01245
    01246                 default:
    01247                     printf( "failed to read\r\n" ) ;
    01248                 break ;
    01249             }
    01250         }
    01251         else // failed read
    01252         {
    01253             printf( "failed to read\r\n" ) ;
    01254         }
    01255
    01256         f_close( &fp ) ;
    01257
    01258         return SAMGUI_E_OK ;
    01259     }
    01260     else
    01261     {
    01262         SGUIColor clr={ .u.dwRGBA=0xff0000 } ;
    01263
    01264         printf( "failed to open %s\r\n", (const char*)pucData ) ;
    01265
    01266         _DBE_ILI9325_DrawFilledRectangle( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, NULL, &clr ) ;
    01267         clr.u.dwRGBA=0x000000 ;
    01268
    01269         _DBE_ILI9325_DrawLine( dwX, dwY, dwX+dwWidth-1, dwY+dwHeight-1, &clr ) ;
    01270         _DBE_ILI9325_DrawLine( dwX, dwY+dwHeight-1, dwX+dwWidth-1, dwY, &clr ) ;
    01271     }
    01272
    01273     return SAMGUI_E_FILE_OPEN ;
    01274 }
    01275
    01276 static uint32_t _DBE_ILI9325_DrawBitmap( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData )
    01277 {
    01278     uint32_t dwCol ;
    01279 //#ifdef ILI9325_BGR_MODE
    01280 //    uint8_t ucB ;
    01281 //    uint8_t ucG ;
    01282 //    uint8_t ucR ;
    01283 //#endif // ILI9325_BGR_MODE
    01284
    01285     // Check if bitmap is Microsoft BMP
    01286     if ( (pucData[0] == 'B') && (pucData[1] == 'M') )
    01287     {
    01288         return _DBE_ILI9325_DrawBitmapBMP( dwX, dwY, dwWidth, dwHeight, pucData ) ;
    01289     }
    01290
    01291     if ( pucData[0] == '/' )
    01292     {
    01293         return _DBE_ILI9325_DrawBitmapBMPFile( dwX, dwY, dwWidth, dwHeight, pucData ) ;
    01294     }
    01295
    01296     // Draw raw RGB bitmap
    01297     _DBE_ILI9325_SetWindow( dwX, dwY, dwWidth, dwHeight ) ;
    01298     _DBE_ILI9325_SetCursor( dwX, dwY ) ;
    01299
    01300     ILI9325_IR=0 ;
    01301     ILI9325_IR=TS_INS_RW_GRAM ;
    01302
    01303 #ifdef ILI9325_BGR_MODE
    01304 //    _DBE_ILI9325_SetBGRMode() ;
    01305 #endif // ILI9325_RGB_MODE
    01306
    01307 #ifdef ILI9325_RGB_MODE
    01308 //    _DBE_ILI9325_SetBGRMode() ;
    01309 #endif // ILI9325_RGB_MODE
    01310
    01311     for ( dwCol=0 ; dwCol < dwWidth*dwHeight ; dwCol++ )
    01312     {
    01313 #ifdef ILI9325_BGR_MODE
    01314         ucB=((*pucData++)/*<<2*/) ;
    01315         ucG=((*pucData++)/*<<2*/) ;
    01316         ucR=((*pucData++)/*<<2*/) ;
    01317         ILI9325_D=ucR/*<<2*/ ;
    01318         ILI9325_D=ucG/*<<2*/ ;
    01319         ILI9325_D=ucB/*<<2*/ ;
    01320 #endif // ILI9325_BGR_MODE
    01321
    01322 #ifdef ILI9325_RGB_MODE
    01323         ILI9325_D = ((*pucData++)/*<<2*/) ;
    01324         ILI9325_D = ((*pucData++)/*<<2*/) ;
    01325         ILI9325_D = ((*pucData++)/*<<2*/) ;
    01326 #endif // ILI9325_RGB_MODE
    01327     }
    01328
    01329 #ifdef ILI9325_BGR_MODE
    01330 //    _DBE_ILI9325_SetBGRMode() ;
    01331 #endif // ILI9325_RGB_MODE
    01332
    01333 #ifdef ILI9325_RGB_MODE
    01334 //    _DBE_ILI9325_SetRGBMode() ;
    01335 #endif // ILI9325_RGB_MODE
    01336
    01337     _DBE_ILI9325_SetWindow( dwX, dwY, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    01338
    01339     return SAMGUI_E_OK ;
    01340 }
    01341
    01342 static uint32_t _DBE_ILI9325_DrawChar( uint32_t dwX, uint32_t dwY, uint8_t ucChar, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize )
    01343 {
    01344     uint32_t dwRow ;
    01345     uint32_t dwCol ;
    01346
    01347 //    assert( (ucChar >= 0x20) && (ucChar <= 0x7F) ) ;
    01348
    01349     for ( dwCol=0 ; dwCol < 10 ; dwCol++ )
    01350     {
    01351         for ( dwRow=0 ; dwRow < 8 ; dwRow++ )
    01352         {
    01353             if ( (aucFont10x14[((ucChar - 0x20) * 20) + dwCol * 2] >> (7 - dwRow)) & 0x1)
    01354             {
    01355                 _DBE_ILI9325_DrawPixel( dwX+dwCol, dwY+dwRow, pclrText ) ;
    01356             }
    01357         }
    01358
    01359         for ( dwRow=0 ; dwRow < 6 ; dwRow++ )
    01360         {
    01361             if ( (aucFont10x14[((ucChar - 0x20) * 20) + dwCol * 2 + 1] >> (7 - dwRow)) & 0x1)
    01362             {
    01363                 _DBE_ILI9325_DrawPixel( dwX+dwCol, dwY+dwRow+8, pclrText ) ;
    01364             }
    01365         }
    01366     }
    01367
    01368     return SAMGUI_E_OK ;
    01369 }
    01370
    01371 static uint32_t _DBE_ILI9325_DrawText( uint32_t dwX, uint32_t dwY, char* pszText, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize )
    01372 {
    01373     uint32_t dwXOrg=dwX ;
    01374
    01375     if ( (pszText == NULL) || (pclrText == NULL) || (pFont == NULL) )
    01376     {
    01377         return SAMGUI_E_BAD_POINTER ;
    01378     }
    01379
    01380     while ( *pszText != 0 )
    01381     {
    01382         if ( *pszText == '\n' )
    01383         {
    01384             dwY+=pFont->dwHeight+2 ;
    01385             dwX=dwXOrg ;
    01386         }
    01387         else
    01388         {
    01389             _DBE_ILI9325_DrawChar( dwX, dwY, *pszText, pclrText, pFont, dwSize ) ;
    01390             dwX+=pFont->dwWidth+2 ;
    01391         }
    01392         pszText++ ;
    01393     }
    01394
    01395     return SAMGUI_E_OK ;
    01396 }
    01397
    01398 static uint32_t _DBE_ILI9325_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
    01399 {
    01400     // Check pointers
    01401 //    if ( (pdwValue == NULL) || (pdwValueLength == NULL) )
    01402 //    {
    01403 //        return SAMGUI_E_BAD_POINTER ;
    01404 //    }
    01405
    01406     switch ( dwCommand )
    01407     {
    01408         case DISP_BACKEND_IOCTL_POWER_ON :
    01409             _DBE_ILI9325_LCD_On() ;
    01410         break ;
    01411
    01412         case DISP_BACKEND_IOCTL_POWER_OFF :
    01413             _DBE_ILI9325_LCD_Off() ;
    01414         break ;
    01415
    01416         case DISP_BACKEND_IOCTL_SET_BACKLIGHT :
    01417             _DBE_ILI9325_SetBacklight( (uint32_t)pdwValue ) ;
    01418         break ;
    01419
    01420         case DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT :
    01421             _DBE_ILI9325_SetOrientation( DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT ) ;
    01422         break ;
    01423
    01424         case DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE :
    01425             _DBE_ILI9325_SetOrientation( DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE ) ;
    01426         break ;
    01427
    01428         default :
    01429             printf( "_DBE_ILI9325_IOCtl - Bad IOCtl index (%x)\r\n", dwCommand ) ;
    01430         break ;
    01431     }
    01432
    01433     return SAMGUI_E_OK ;
    01434 }
    01435
    01436 /*----------------------------------------------------------------------------
    01437  *        Exported interface
    01438  *----------------------------------------------------------------------------*/
    01439 SDISPBackend sDISP_Backend_ILI9325=
    01440 {
    01441     .sData=
    01442     {
    01443         .dwID=DISP_BACKEND_ILI9325,
    01444     },
    01445
    01446     .Reset=_DBE_ILI9325_Reset,
    01447     .Initialize=_DBE_ILI9325_Initialize,
    01448     .GetPixel=_DBE_ILI9325_GetPixel,
    01449     .DrawPixel=_DBE_ILI9325_DrawPixel,
    01450     .DrawLine=_DBE_ILI9325_DrawLine,
    01451     .DrawCircle=_DBE_ILI9325_DrawCircle,
    01452     .DrawFilledCircle=_DBE_ILI9325_DrawFilledCircle,
    01453     .DrawRectangle=_DBE_ILI9325_DrawRectangle,
    01454     .DrawFilledRectangle=_DBE_ILI9325_DrawFilledRectangle,
    01455     .DrawBitmap=_DBE_ILI9325_DrawBitmap,
    01456     .DrawText=_DBE_ILI9325_DrawText,
    01457     .Fill=NULL,
    01458     .IOCtl=_DBE_ILI9325_IOCtl
    01459 } ;

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines