/******************************************************************************** ********************************************************************************** ** Project Name: T658 ** File Name: tft_S6D0151.c ** Description: This file contains driver for color LCD. LCD type : TFT Driver IC: S6D0151 Dot pixcel:128*160 Menufacture: Truly ** Current Ver: 1.0 ** Author: Huangfusheng ** DATE: 10/08/2007 ** Displace Ver: *** ** Author : *** ** Data : *** ******************************************************************************** ********************************************************************************/ #include "os_api.h" #include "sci_types.h" //#include "lcd_api.h" #include "gpio_api.h" #include "lcd.h" // #include "mv3lib.h" #ifdef __cplusplus extern "C" { #endif /**---------------------------------------------------------------------------* ** Macro Define **---------------------------------------------------------------------------*/ #define S6D0151_WIDTH 128//176 #define S6D0151_HEIGHT 160//220 #define MP4_MAX_WIDTH 176 #define MP4_MAX_HEIGHT 144 #define OFFSET_X 0 //@David.Jia 2005.11.22 #define ADC_S6D0151_LOW 231 #define ADC_S6D0151_HIGH 249 //@David.Jia 2006.3.3 cr42033 #define LCD_USE_DMA #define WR_GRAM_COMMAND 0x0022 extern void dma_init(void); extern void *LCD_GetLCDBuffer(void); /******************************************************************************/ // Description: Clear color LCD with one color // Global resource dependence: // Author: louis.wei // Note: /******************************************************************************/ LOCAL void S6D0151_Clear( uint32 color //color to fill the whole lcd. ); /******************************************************************************/ // Description: Close the lcd.(include sub lcd.) // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL void S6D0151_Close(void); /******************************************************************************/ // Description: Enter/Exit sleep mode . // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_EnterSleep( BOOLEAN is_sleep //SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode. ); /*****************************************************************************/ // Description: Get the lcd base information.. // Global resource dependence: // Author: louis.wei // Note: /*****************************************************************************/ LOCAL ERR_LCD_E S6D0151_GetInfo( LCD_INFO_T *lcd_info_ptr //lcd information struct pointer ); /******************************************************************************/ // Description: get the important parameter for digital camera // Global resource dependence: // Author: Zhemin.lin // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_GetMainLcdSpec( LCD_SPEC_T *spec_ptr //spec struct pointer ); /*********************************************************************/ // Description: Initialize color LCD : S6D0151 // Input: // None. // Return: // None. // Note: /*********************************************************************/ LOCAL ERR_LCD_E S6D0151_Init(void); /******************************************************************************/ // Description: invalidate a rectang of in LCD // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_Invalidate(void); /******************************************************************************/ // Description: Copy a retangle data from clcd_buffer to display RAM. // then the rectangle display is to be refreshed // Global resource dependence: // Author: Jim.zhang // Note: // To improve speed, lcd is operate in HIGH SPEED RAM WRITE MODE(4 // uint16 are write continuously always.) So, some dummy uint16 // should be inserted to satisfy this mode. Please refer to spec. /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_InvalidateRect( uint16 left, //the left value of the rectangel uint16 top, //top of the rectangle uint16 right, //right of the rectangle uint16 bottom //bottom of the rectangle ); /******************************************************************************/ // Description: for mp4 display // Global resource dependence: // Author: juan.zhang /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_InvalidateRectImage( uint16 left, //the left value of the rectangel uint16 top, //top of the rectangle uint16 right, //right of the rectangle uint16 bottom, //bottom of the rectangle uint16 *buf_ptr, uint8 is_invert//ignore ); /******************************************************************************/ // Description: LCD go to sleep mode // Author: Yingchun.li // Note: /******************************************************************************/ LOCAL S6D0151_GoSleep(void); /******************************************************************************/ // Description: LCD exit sleep mode // Author: Yingchun.li // Note: /******************************************************************************/ LOCAL S6D0151_ExitSleep(void); LOCAL void main_lcd_fill_rect(uint16 left, uint16 top,uint16 right, uint16 bottom,uint16 color); /**---------------------------------------------------------------------------* ** Function Definitions **---------------------------------------------------------------------------*/ extern uint32 dma_request(uint32 chid, uint32 saddr, uint32 daddr, uint32 size, uint32 transfer_mode, uint32 size_mode); #define S6D0151_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;} #define S6D0151_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;} #define S6D0151_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;} LOCAL void S6D0151_reset(void) { uint16 lcm_nv = REFPARAM_GetLCDType(); SCI_TRACE_LOW("S6D0151_reset: 7370 GG3728 S6D0151/HYDIS."); switch(lcm_nv) { // case TFT_S6D0151_Truly: //for S6D0151 S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0020); S6D0151_SEND_COMMAND(0x00b6); S6D0151_SEND_DATA(0x013f); S6D0151_SEND_COMMAND(0x00B4); S6D0151_SEND_DATA(0x0010); S6D0151_SEND_COMMAND(0x0012); S6D0151_SEND_DATA(0x00b2); S6D0151_SEND_COMMAND(0x0013); S6D0151_SEND_DATA(0x080e); S6D0151_SEND_COMMAND(0x0014); S6D0151_SEND_DATA(0x5BCA); S6D0151_SEND_COMMAND(0x0061); S6D0151_SEND_DATA(0x0018); S6D0151_SEND_COMMAND(0x0010); S6D0151_SEND_DATA(0x190C); Delayms(80); S6D0151_SEND_COMMAND(0x0013); S6D0151_SEND_DATA(0x081e); Delayms(20); S6D0151_SEND_COMMAND(0x0001); S6D0151_SEND_DATA(0x0114); S6D0151_SEND_COMMAND(0x0002); S6D0151_SEND_DATA(0x0100); S6D0151_SEND_COMMAND(0x0003); S6D0151_SEND_DATA(0x0030); S6D0151_SEND_COMMAND(0x0008); S6D0151_SEND_DATA(0x0202); S6D0151_SEND_COMMAND(0x000b); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x000C); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0061); S6D0151_SEND_DATA(0x0018); S6D0151_SEND_COMMAND(0x0069); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0070); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0071); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0011); S6D0151_SEND_DATA(0x0000); ///////r CONTROL S6D0151_SEND_COMMAND(0x0030); S6D0151_SEND_DATA(0x0303); S6D0151_SEND_COMMAND(0x0031); S6D0151_SEND_DATA(0x0303); S6D0151_SEND_COMMAND(0x0032); S6D0151_SEND_DATA(0x0303); S6D0151_SEND_COMMAND(0x0033); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0034); S6D0151_SEND_DATA(0x0404); S6D0151_SEND_COMMAND(0x0035); S6D0151_SEND_DATA(0x0404); S6D0151_SEND_COMMAND(0x0036); S6D0151_SEND_DATA(0x0404); S6D0151_SEND_COMMAND(0x0037); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0038); S6D0151_SEND_DATA(0x0707); ///////Coordinatioontrol setting S6D0151_SEND_COMMAND(0x0040); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0042); S6D0151_SEND_DATA(0x9F00); S6D0151_SEND_COMMAND(0x0043); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0044); S6D0151_SEND_DATA(0x7F00); S6D0151_SEND_COMMAND(0x0045); S6D0151_SEND_DATA(0x9F00); S6D0151_SEND_COMMAND(0x0069); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0070); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0071); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0073); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x00B3); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x00BD); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x00BE); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0021); S6D0151_SEND_DATA(0x0000); S6D0151_SEND_COMMAND(0x0022); Delayms(20); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0020); Delayms(5); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0021); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0027); Delayms(50); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0037); break; } } /******************************************************************************/ // Description: Clear color LCD with one color // Global resource dependence: // Author: louis.wei // Note: // modify: jim.cui 2005.0728 use dma to transport data /******************************************************************************/ LOCAL void S6D0151_Clear( uint32 color //color to fill the whole lcd. ) { uint32 i; uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer(); uint16 fill_color = color; for(i=0; i<(S6D0151_HEIGHT ); i++) { dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * S6D0151_WIDTH), S6D0151_WIDTH, 1, 1); } S6D0151_Invalidate(); } /******************************************************************************/ // Description: Set the windows address to display, in this windows // color is refreshed. // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ __inline void S6D0151_set_display_window( uint8 left, // start Horizon address uint8 top, // start Vertical address uint8 right, // end Horizon address uint8 bottom // end Vertical address ) { uint16 addr1,addr2; addr1 = (((right&0xff)<<8)|(left&0xff)); addr2 = (((bottom&0xff)<<8)|(top&0xff)); S6D0151_SEND_COMMAND(0x0044); S6D0151_SEND_DATA(addr1); S6D0151_SEND_COMMAND(0x0045); S6D0151_SEND_DATA(addr2); } /******************************************************************************/ // Description: Set start RAM address which is write to AC(Address // Counter) register. // Input: // left: start Horizon address of AC // top: start Vertical address of AC. // Return: // None. // Note: /******************************************************************************/ __inline void S6D0151_set_start_address( uint8 left, uint8 top ) { uint16 addr; addr = (((top&0xff)<<8)|(left&0xff)); S6D0151_SEND_COMMAND(0x0021); S6D0151_SEND_DATA(addr); } /******************************************************************************/ // Description: invalidate a rectang of in LCD // Global resource dependence: // Author: Jim.zhang // Note: // modify: jim.cui 2005.0728 use dma to transport data /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_Invalidate(void) { uint16 i,j; //uint16 address = 0; uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer(); #ifdef LCD_USE_DMA //uint32 dummy_before,dummy_after; S6D0151_set_display_window(0, 0, S6D0151_WIDTH-1, S6D0151_HEIGHT-1); S6D0151_set_start_address(0, 0); /* address = (uint16) ( (((S6D0151_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X)); S6D0151_sendcommand1(0x44, address); // set horizon address address = (uint16) ( ((S6D0151_HEIGHT-1) & 0xFF) << 8 ); S6D0151_sendcommand1(0x45, address); // set vertical address S6D0151_sendcommand1(0x0021, OFFSET_X); */ //S6D0151_SEND_COMMAND(0x0017); // send data. //dummy_before = 1 % 4; // Inserted numbers befor every arrow. //dummy_after = 3 - (S6D0151_WIDTH % 4); // Inserted numbers after every arrow. for(j=0; j<(S6D0151_HEIGHT ); j++) { dma_request(0, (uint32)(buf_ptr + j * S6D0151_WIDTH), 0x58020000, S6D0151_WIDTH, 1, 0); } #else SCI_TRACE_LOW("tft_S6D0151.c S6D0151_Invalidate line%d", __LINE__); S6D0151_set_display_window(0, 0, S6D0151_WIDTH-1, S6D0151_HEIGHT-1); S6D0151_set_start_address(0, 0); /* address = (uint16) ( (((S6D0151_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X)); S6D0151_sendcommand1(0x44, address); // set horizon address address = (uint16) ( ((S6D0151_HEIGHT-1) & 0xFF) << 8 ); S6D0151_sendcommand1(0x45, address); // set vertical address S6D0151_sendcommand1(0x0021, OFFSET_X); */ //S6D0151_SEND_COMMAND(0x0017); // send data. for(i=0; i<(S6D0151_WIDTH * S6D0151_HEIGHT); i++) S6D0151_SEND_DATA( *buf_ptr++ ); #endif return ERR_LCD_NONE; } /*****************************************************************************/ // Description: Get the lcd base information.. // Global resource dependence: // Author: louis.wei // Note: /*****************************************************************************/ LOCAL ERR_LCD_E S6D0151_GetInfo( LCD_INFO_T *lcd_info_ptr //lcd information struct pointer ) { if ( PNULL == lcd_info_ptr ) { return ERR_LCD_POINTER_NULL; } lcd_info_ptr->r_bitmask = 0xf800; lcd_info_ptr->g_bitmask = 0x07e0; lcd_info_ptr->b_bitmask = 0x001f; lcd_info_ptr->bits_per_pixel = 16; lcd_info_ptr->contrast_min = 0x00; lcd_info_ptr->contrast_max = 63; lcd_info_ptr->contrast_defaut = 0x0A; lcd_info_ptr->lcd_width = S6D0151_WIDTH; lcd_info_ptr->lcd_height = S6D0151_HEIGHT; lcd_info_ptr->lcdbuff_ptr = (void *)LCD_GetLCDBuffer(); return ERR_LCD_NONE; } /******************************************************************************/ // Description: Copy a retangle data from clcd_buffer to display RAM. // then the rectangle display is to be refreshed // Global resource dependence: // Author: Jim.zhang // Note: // To improve speed, lcd is operate in HIGH SPEED RAM WRITE MODE(4 // uint16 are write continuously always.) So, some dummy uint16 // should be inserted to satisfy this mode. Please refer to spec. // modify: jim.cui 2005.0728 use dma to transport data /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_InvalidateRect( uint16 left, //the left value of the rectangel uint16 top, //top of the rectangle uint16 right, //right of the rectangle uint16 bottom //bottom of the rectangle ) { uint32 i, j; uint32 dummy_before, dummy_after; uint32 row, column,rect_width; uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer(); //**************************************************** //**************************************************** if (LCD_GetRefreshFlag() != TRUE ) { SCI_TRACE_LOW(" LCD_GetRefreshFlag"); return ERR_LCD_OPERATE_FAIL ; } //***************************************************** //SCI_TRACE_LOW("tft_S6D0151.c S6D0151_InvalidateRect line%d: left = %d, top = %d, right = %d, bottom = %d", __LINE__, left, top, right,bottom); left = (left >= S6D0151_WIDTH) ? S6D0151_WIDTH-1 : left; right = (right >= S6D0151_WIDTH) ? S6D0151_WIDTH-1 : right; top = (top >= S6D0151_HEIGHT) ? S6D0151_HEIGHT-1 : top; bottom = (bottom >= S6D0151_HEIGHT) ? S6D0151_HEIGHT-1 : bottom; if ( ( right < left ) || ( bottom < top ) ) { return ERR_LCD_PARAMETER_WRONG; } S6D0151_set_display_window(left, top, right, bottom); // In High Speed RAM Write Mode. Maybe some dummy data are insterted. //dummy_before = (left) % 4; // Inserted numbers befor every arrow. //dummy_after = 3 - (right % 4); // Inserted numbers after every arrow. #ifdef LCD_USE_DMA S6D0151_set_start_address(left, top); S6D0151_SEND_COMMAND(WR_GRAM_COMMAND); // send data. rect_width = right-left+1; for (j = top; j <= bottom; j++) { dma_request(0, (uint32)(buf_ptr + j * S6D0151_WIDTH+left), 0x58020000, rect_width, 1, 0); } #else row = bottom - top; column = right - left; S6D0151_set_start_address(left - dummy_before, top); //S6D0151_SEND_COMMAND(0x17); // send data. for (i = 0; i <= row; i++) { for(j = 0; j= MP4_MAX_WIDTH) ? MP4_MAX_WIDTH-1 : left; right = (right >= MP4_MAX_WIDTH) ? MP4_MAX_WIDTH-1 : right; top = (top >= MP4_MAX_HEIGHT) ? MP4_MAX_HEIGHT-1 : top; bottom = (bottom >= MP4_MAX_HEIGHT) ? MP4_MAX_HEIGHT-1 : bottom; left = 0; right = 127; top = 0; bottom = 159; //175; if ( ( right < left ) || ( bottom < top ) ) { return ERR_LCD_PARAMETER_WRONG; } SCI_TRACE_LOW("tft_S6D0151.c S6D0151_InvalidateRectImage() left=%d,right=%d,top=%d,bottom=%d,is_invert=%d line%d", left,right,top,bottom,is_invert,__LINE__); if (is_invert) { S6D0151_sendcommand1(0x03,0x0028 ); } else { S6D0151_sendcommand1(0x03,0x0030 ); } S6D0151_set_display_window(left, top, right, bottom); // In High Speed RAM Write Mode. Maybe some dummy data are insterted. dummy_before = (left) % 4; // Inserted numbers befor every arrow. dummy_after = 3 - (right % 4); // Inserted numbers after every arrow. #if 1 // S6D0151_set_display_window(left, top, right, bottom); if (is_invert) { S6D0151_set_start_address(right, top); } else { S6D0151_set_start_address(left, top); } S6D0151_SEND_COMMAND(WR_GRAM_COMMAND); // send data. if (is_invert) { for (j = left; j <= right; j++) { for (i = top; i <= bottom; i++) { S6D0151_SEND_DATA( *(buf_ptr + j * 176 + i) ); } } } else { for (j = top; j <= bottom; j++) { for (i = left; i <= right; i++) { S6D0151_SEND_DATA( *(buf_ptr + j * 176 + i) ); } } } #endif S6D0151_sendcommand1(0x03,0x0030 ); return ERR_LCD_NONE; } /*@Zhemin.Lin, CR9122, begin*/ static LCD_SPEC_T g_S6D0151_spec = { 0, //uint8 rgb_sequence; /*rgb sequence*/ /*0: R-G-B, 1: B-G-R*/ 10, //uint8 min_cycle_read; /*read cycle: ns*/ 50, //uint8 min_cycle_write; /*write cycle: ns*/ 0, //uint8 cyclenum_sendaddr; /*operation cycle to send address*/ /* 0: once, 1:twice*/ 0, //uint8 cyclenum_senddata; /*operation cycle to send data */ /* 0; once, 1:twice*/ 1, //uint8 cmd_num_setupwin; /*command number to settint up widnow space*/ /*0: 4 commands for setting up window space: x-start, x-end, y-start, y-end*/ /*1: 2 commands for setting up window space: x-address, y-address*/ /*2: 1 commanns for setting up window space window address*/ /*3: no commands for setting up window space*/ 1, //uint8 method_send_cmdaddr;/*how to send command & address*/ /*0: sending together, 1:sending separately*/ 1, //uint8 ads_is_high; /*status of ADS when sending parameter*/ /*0: low, 1: high*/ 0, //uint8 sequence_cmdaddr; /*the sequence of command & address, if not send command & address together as 16 bits*/ /*0: write 2 window area on a 16bit bus, Hitachi*/ /*1, write 1 sindow area with one command, Casio*/ /*2, write 1 command and 2 parameters separately, Samsung*/ /*3, reserved*/ /*4, write 1 command, 2 parameters for page, 4 parameters for column, Epson*/ /*5, write 1 command, 4 parameters for page, 2 parameters for column*/ /*6, write 1 command, write 4 parameters for each page/column*/ 4, //uint8 cyclenum_setupwin; /*operation cycle to set up window*/ 1, //uint8 method_gram_access; /*select method to begin actul data read/write address for selected window area in GRAM*/ /*0: without any assigning x/y address, use initial start address of window*/ /*1: assign 1 x/y set command and parameter onto 16bit bus at onece*/ /*2: use separate for X and Y, with upper byte consists of command and lower byte for parameter*/ /*3, 1 command for selecting X/Y adn 2 parameters, us command and parameter separately*/ /*4, set different command for x and y, and command and parameter differs*/ 1, //uint8 sequence_gram_access;/*read/write command and sequence for GRAM*/ /*0: perform read/write without seperate read/write command but by strobe 'high' ADS(RS)pin, samsung*/ /*1: data cycle comes right afer read/write command, Toshiba/Matsushita/Hitachi/NEC*/ /*2: after read/write command follows start address parameter for X and Y and follows data cycle, Casio*/ /*3: similiar to 2 but sends X and Y parameters together on 16 bit BUS*/ 0, //uint8 order_xy; /*order of x and y address, I think, this field is active when sequence_gram_access = 2*/ /*0: X first*/ /*1: Y first*/ 1, //uint8 is_dummy_read; /*deciding first read data when reading GRAM*/ /*0: acknowledge first data as valid data*/ /*1: acknowledge first data as dummy data*/ 3, //uint8 cyclenum_read; /*total cycle numbers needed to access GRAM read/write*/ 0x44, //uint8 win_setstartx_cmd; /*window x start address set command*/ 0x00, //uint8 win_setendx_cmd; /*window x end address set command*/ 0x45, //uint8 win_setstarty_cmd; /*window y start address set command*/ 0x00, //uint8 win_setendy_cmd; /*window y end address set command*/ 0x21, //uint8 gram_setx_cmd; /*gram x address set command*/ 0x00, //uint8 gram_sety_cmd; /*gram y address set command*/ 0x22, //uint8 gram_read_cmd; /*gram read command*/ 0x22, //uint8 gram_write_cmd; /*gram write command*/ //@zhemin.lin, add 1 line, CR9590 0x00, //uint8 line_offset; /*line offset for display on lcd*/ 0x00 //uint8 colum_offset /*columoffset for display on lcd*/ }; /******************************************************************************/ // Description: get the important parameter for digital camera // Global resource dependence: // Author: Zhemin.lin // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_GetMainLcdSpec( LCD_SPEC_T *spec_ptr //spec struct pointer ) { if (spec_ptr == PNULL) { return 1; } memcpy(spec_ptr, &g_S6D0151_spec, sizeof(LCD_SPEC_T)); return ERR_LCD_NONE; } /******************************************************************************/ // Description: Enter/Exit sleep mode . // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_EnterSleep( BOOLEAN is_sleep //SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode. ) { SCI_TRACE_LOW("S6D0151_EnterSleep,%d", is_sleep); if ( is_sleep ) // enter sleep mode. { S6D0151_GoSleep(); } else // out sleep mode { //S6D0151_reset(); S6D0151_ExitSleep(); } /* if( !GetUdiskState()) DC_EnterSleep(is_sleep); */ return ERR_LCD_NONE; } /*****************************************************************************/ // Description: Enable lcd to partial display mode, so can save power. // Global resource dependence: // Author: Jim.zhang // Return: SCI_TRUE:SUCCESS ,SCI_FALSE:failed. // Note: If all input parameters are 0, exit partial display mode. /*****************************************************************************/ LOCAL ERR_LCD_E S6D0151_SetDisplayWindow( uint16 left, //left of the window uint16 top, //top of the window uint16 right, //right of the window uint16 bottom //bottom of the window ) { S6D0151_set_display_window(left, top, right, bottom); S6D0151_set_start_address(left, top); //@David.Jia 2005.12.26 //S6D0151_SEND_COMMAND(0x0022); //@David.Jia 2005.12.26 return ERR_LCD_NONE; } /*********************************************************************/ // Description: Initialize color LCD : S6D0151 // Input: // None. // Author: yinchun.li // Return: // None. // Note: // modify: jim.cui 2005.0728 add dma init /*********************************************************************/ LOCAL ERR_LCD_E S6D0151_Init(void) { //dma init dma_init (); //S6D0151_HW_reset(); S6D0151_reset(); S6D0151_Clear( 0xf25f ); return ERR_LCD_NONE; } /******************************************************************************/ // Description: set the contrast value // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL ERR_LCD_E S6D0151_SetContrast( uint16 contrast //contrast value to set ) { return ERR_LCD_FUNC_NOT_SUPPORT; } /*****************************************************************************/ // Description: Set the brightness of LCD. // Global resource dependence: // Author: Jim.zhang // Note: /*****************************************************************************/ LOCAL ERR_LCD_E S6D0151_SetBrightness( uint16 brightness //birghtness to set ) { return ERR_LCD_FUNC_NOT_SUPPORT; } /******************************************************************************/ // Description: Close the lcd.(include sub lcd.) // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ LOCAL void S6D0151_Close() { GPIO_SetLcdBackLight( SCI_FALSE ); S6D0151_EnterSleep( SCI_TRUE ); } LOCAL LCD_OPERATIONS_T S6D0151_operations = { S6D0151_Init, S6D0151_EnterSleep, S6D0151_SetContrast, S6D0151_SetBrightness, S6D0151_SetDisplayWindow, S6D0151_GetInfo, S6D0151_InvalidateRect, S6D0151_InvalidateRectImage, S6D0151_Invalidate, S6D0151_Clear, S6D0151_Close, S6D0151_GetMainLcdSpec }; /******************************************************************************/ // Description: return the S6D0151 lcd driver funtion pointer // Global resource dependence: // Author: Jim.zhang // Note: /******************************************************************************/ PUBLIC LCD_OPERATIONS_T* S6D0151_GetOperations() { return &S6D0151_operations; } #define ADC_NUM 10 PUBLIC BOOLEAN S6D0151_Probe(void) { return SCI_TRUE; } LOCAL S6D0151_GoSleep(void) { S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0136); //GON=1,DTE=1,D1-0=10 Delayms(30); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0126); //GON=1,DTE=0,D1-0=10 Delayms(30); S6D0151_SEND_COMMAND(0x0007); S6D0151_SEND_DATA(0x0124); //GON=1,DTE=0,D1-0=00 Delayms(30); S6D0151_SEND_COMMAND(0x0010); S6D0151_SEND_DATA(0x0000); //SAP2-0=000, AP2-0=000 S6D0151_SEND_COMMAND(0x0013); S6D0151_SEND_DATA(0x0000); //PON=0 Delayms(100); S6D0151_SEND_COMMAND(0x0010); S6D0151_SEND_DATA(0x0002); //SLP=1 } LOCAL S6D0151_ExitSleep(void) { S6D0151_reset(); } #if 1 LOCAL void main_lcd_fill_rect(uint16 left, uint16 top,uint16 right, uint16 bottom,uint16 color) { uint16 i,j; uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer(); for(i = top; i < bottom;i++) { for(j = left; j < right; j++) { *(buf_ptr+i*S6D0151_WIDTH+j)=color; } } } void main_lcd_test() { unsigned long i; //GPIO_SetLcdReset( 0 ); //lcd hardware reset. //for(i=0; i<3500; i++); //GPIO_SetLcdReset( 1 ); GPIO_SetLcdBackLight( SCI_TRUE );//set backlight S6D0151_reset();// lcd init for(i=0; i<3500; i++); main_lcd_fill_rect(0,0,S6D0151_WIDTH,S6D0151_HEIGHT/3,0xf800);//r main_lcd_fill_rect(0,S6D0151_HEIGHT/3,S6D0151_WIDTH,(2*S6D0151_HEIGHT)/3,0x07e0);//g main_lcd_fill_rect(0,(2*S6D0151_HEIGHT)/3,S6D0151_WIDTH,S6D0151_HEIGHT,0x001f);//g S6D0151_Invalidate(); for(i=0; i<3500; i++); main_lcd_fill_rect(0,0,S6D0151_WIDTH,S6D0151_HEIGHT,0x5171);//r S6D0151_InvalidateRect(0,0,20,30); //for(i=0; i<3500; i++); //while(1); } #endif /**---------------------------------------------------------------------------* ** Compiler Flag * **---------------------------------------------------------------------------*/ #ifdef __cplusplus } #endif