⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tft_r61500.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
										/*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*/
	0x16,	//uint8	win_setstartx_cmd;	/*window x start address set command*/
	0x00,	//uint8	win_setendx_cmd;	/*window x end address set command*/
	0x17,	//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*/
};
#endif

/******************************************************************************/
//  Description:    get the important parameter for digital camera
//	Global resource dependence: 
//  Author:         Zhemin.lin
//	Note:           
/******************************************************************************/
LOCAL ERR_LCD_E  R61500_GetMainLcdSpec(
	LCD_SPEC_T *spec_ptr 	//spec struct pointer
	)
{
	if (spec_ptr == PNULL)
	{
		return 1;
	}
	
	memcpy(spec_ptr, &g_R61500_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  R61500_EnterSleep(
	BOOLEAN is_sleep 	//SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
	)
{
	SCI_TRACE_LOW("R61500_EnterSleep,%d", is_sleep);
	
	
	if ( is_sleep ) // enter sleep mode.
	{
     
        R61500_GoSleep();        
		
	}
	else 			// out sleep mode 
	{

		//R61500_reset();
		R61500_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 R61500_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
	)
{
    R61500_set_display_window(left, top, right, bottom);
    
    R61500_sendcommand1(0x0021, OFFSET_X);		//@David.Jia 2005.12.26

	R61500_SEND_COMMAND(0x0022); 				//@David.Jia 2005.12.26
    
	return ERR_LCD_NONE;
}

/*********************************************************************/
//  Description:   Initialize color LCD : R61500
//  Input:
//      None.
//  Author:         yinchun.li
//  Return:
//      None.
//	Note:
//  modify:  jim.cui  2005.0728 add dma init  
/*********************************************************************/
LOCAL ERR_LCD_E R61500_Init(void)
{

       //dma init
       dma_init ();

 	//R61500_HW_reset();
   	R61500_reset();

	R61500_Clear( 0xf25f );

	
	return ERR_LCD_NONE;
}


/******************************************************************************/
//  Description:  set the contrast value 
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E   R61500_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   R61500_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 R61500_Close()
{
    GPIO_SetLcdBackLight( SCI_FALSE );
    R61500_EnterSleep( SCI_TRUE );	
}


LOCAL LCD_OPERATIONS_T R61500_operations = 
{
	R61500_Init,
	R61500_EnterSleep,
	R61500_SetContrast,
	R61500_SetBrightness,
	R61500_SetDisplayWindow,
	R61500_GetInfo,
	R61500_InvalidateRect,
	R61500_InvalidateRectImage,
	R61500_Invalidate,
	R61500_Clear,
	R61500_Close,
	R61500_GetMainLcdSpec
};

/******************************************************************************/
//  Description:  return the R61500 lcd driver funtion pointer
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC LCD_OPERATIONS_T* R61500_GetOperations()
{
	return &R61500_operations;
}

#define ADC_NUM 10
PUBLIC BOOLEAN R61500_Probe(void)
{
#if 0
    uint32 i, adc_val = 0, adc_sum = 0;
	
	//Delayms(500);
		
	/*for(i=0; i<ADC_NUM; i++)
	{
	    adc_val = ADC_GetResultDirectly(ADIN_1, FALSE);
	    adc_sum += adc_val;
	    SCI_TRACE_LOW("adc_rlt[%d]: %d", i, adc_val);
	    Delayms(50);
	}
	
	adc_val = adc_sum / ADC_NUM;*/
	
	adc_val = LCD_GetADCValue(ADIN_1);//added by lipengyu.
	SCI_TRACE_LOW("average adc_val: %d", adc_val);
	
	if((adc_val >= ADC_R61500_LOW) && (adc_val <= ADC_R61500_HIGH))        //TRULY 3728
	{
	    return SCI_TRUE;	
	}
	
	return SCI_FALSE;
#endif
	return SCI_TRUE;	
}


LOCAL R61500_GoSleep(void)
{
#ifdef LCD_TRULY  
	R61500_sendcommand1(0x0007, 0x0036);	
	Delayms(30); 
	R61500_sendcommand1(0x0007, 0x0026);
	Delayms(30); 
	R61500_sendcommand1(0x0007, 0x0004);

	//power off
	R61500_sendcommand1(0x0010, 0x0000);	
	R61500_sendcommand1(0x0012, 0x0000);
	R61500_sendcommand1(0x0013, 0x0000);

	Delayms(50);
	R61500_sendcommand1(0x0010, 0x0002);
	Delayms(50);

#elif defined (LCD_JIUZHENG)	
	R61500_sendcommand1 (0x0007,0x0000);
	Delayms(25);
	R61500_sendcommand1 (0x000E,0x101C);
	Delayms(25);
	R61500_sendcommand1 (0x000D,0x0000);
	Delayms(25);
	R61500_sendcommand1 (0x0009,0x0008);
	Delayms(25);
	R61500_sendcommand1 (0x0003,0x0000);
	Delayms(25);
	R61500_sendcommand1 (0x0003,0x0002);
	Delayms(25);	
#endif	
	
}

LOCAL R61500_ExitSleep(void)
{
#ifdef LCD_TRULY  
	R61500_sendcommand1(0x0010, 0x0000);
	Delayms(30);
	// power setting
	R61500_sendcommand1(0x0000, 0x0001); 
	Delayms(20); 
	R61500_sendcommand1(0x0007, 0x0020);               
	Delayms(30); 
	R61500_sendcommand1(0x0010, 0x0000);
	R61500_sendcommand1(0x0011, 0x0000);
	R61500_sendcommand1(0x0012, 0x0000); 
	R61500_sendcommand1(0x0013, 0x0000);
	Delayms(30);
	R61500_sendcommand1(0x0011, 0x0210);
	R61500_sendcommand1(0x0012, 0x0000); 
	Delayms(10);
	R61500_sendcommand1(0x0013, 0x080e);
	Delayms(10);
	R61500_sendcommand1(0x0014, 0x2517);
	Delayms(10);
	R61500_sendcommand1(0x0010, 0x1910);
	Delayms(10);

	R61500_sendcommand1(0x0013, 0x081e);
	Delayms(100);
	R61500_sendcommand1(0x0007, 0x0021);
	R61500_sendcommand1(0x0007, 0x0023);
	Delayms(30); 

	R61500_sendcommand1(0x0007, 0x0037);
	Delayms(30);

#elif defined (LCD_JIUZHENG)
	R61500_sendcommand1 (0x0003,0x0000);
	Delayms(25);
	R61500_sendcommand1 (0x0003,0x0110);
	Delayms(10);
	R61500_sendcommand1 (0x0009,0x0006);
	Delayms(10);
	R61500_sendcommand1 (0x000D,0x0014);
	Delayms(50);
	R61500_sendcommand1 (0x000E,0x101C);
	Delayms(50);
	R61500_sendcommand1 (0x000E,0x301C);
	Delayms(50);
	R61500_sendcommand1 (0x0007,0x0037);
	Delayms(50);
 #endif
 
}

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*R61500_WIDTH+j)=color;
    }
  }

}

void TestUpdateLcd(void)
{
	main_lcd_fill_rect(0,R61500_WIDTH-1, 0, R61500_HEIGHT-1, 0x0780);	
	while(1)
	{
		R61500_Invalidate();			
	}
}

#if 0
/******************************************************************************/
//  Description:   Set the windows address to display, in this windows
//                 color is  refreshed.
//	Global resource dependence: 
//  Author:         Kevin.lu
//	Note:
/******************************************************************************/
PUBLIC void set_display_win_area(
	uint8 left, 	// start Horizon address
	uint8 top, 		// start Vertical address
	uint8 right, 	// end Horizon address
	uint8 bottom	// end Vertical address
	)
{
	uint16 address = 0;

	address = (uint16) ((((right & 0xFF) + OFFSET_X)<<8) | ((left & 0xFF) + OFFSET_X));
#ifdef LCD_TRULY 	
	R61500_sendcommand1(0x44, address);		// set horizon address
#elif defined (LCD_JIUZHENG)	
	R61500_sendcommand1(0x16, address);		// set horizon address
#endif

	address = (uint16) (((bottom & 0xFF)<<8) | (top & 0xFF));
#ifdef LCD_TRULY 
	R61500_sendcommand1(0x45, address); 	//  set vertical  address position
#elif defined (LCD_JIUZHENG)
	R61500_sendcommand1(0x17, address); 	//  set vertical  address position
#endif
}
#endif
/**---------------------------------------------------------------------------*
 **                         Compiler Flag                                     *
 **---------------------------------------------------------------------------*/
#ifdef   __cplusplus
    }
#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -