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

📄 tft_s0144.c

📁 ARMSTM32 lcd驱动程序集锦
💻 C
📖 第 1 页 / 共 3 页
字号:
		*buf_ptr++ = (uint16)color;
	}
#endif
	S0144_Invalidate();
}

/******************************************************************************/
//  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 S0144_Invalidate(void)
{
	uint16 i,j;
	uint16 address = 0;
	uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
	//uint16 value;
#ifdef LCD_USE_DMA	
	//uint32  dummy_before,dummy_after;

	if(udisk_plugin)
	{
	 	SetAIT701_ByPassMode(1);
	}
	else
	{
		if (LCD_GetRefreshFlag() != TRUE )
		{
		      SCI_TRACE_LOW(" LCD_GetRefreshFlag");
			return ERR_LCD_OPERATE_FAIL ;
		}
	}	
#ifndef DATA_8BIT
	address = (uint16) ( (((S0144_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));

	S0144_sendcommand1(0x44, address);		// set horizon address
	address = (uint16) ( ((S0144_HEIGHT-1) & 0xFF) << 8 );

	S0144_sendcommand1(0x45, address);	// set vertical address
	S0144_sendcommand1(0x0021, OFFSET_X);
	S0144_SEND_COMMAND(0x0022); 			// send data.
#else
	address = (uint16) ( (((S0144_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));
	S0144_SEND_COMMAND(0x4400);		// set horizon address
	S0144_SEND_DATA(address);		// set horizon address
	S0144_SEND_DATA(address<<8);		// set horizon address

	address = (uint16) ( ((S0144_HEIGHT-1) & 0xFF) << 8 );
	S0144_SEND_COMMAND(0x4500);		// set vertical address
	S0144_SEND_DATA(address);		// set vertical address
	S0144_SEND_DATA(address<<8);		// set vertical address

	S0144_SEND_COMMAND(0x2100);
	S0144_SEND_DATA(OFFSET_X);
	S0144_SEND_DATA(OFFSET_X<<8);

	S0144_SEND_COMMAND(0x2200); 			// send data.
#endif
	//dummy_before =  1 % 4;		// Inserted numbers befor every arrow.
	//dummy_after =  3 - (S0144_WIDTH % 4);	// Inserted numbers after every arrow.
#ifndef DATA_8BIT        
	for(j=0; j<(S0144_HEIGHT ); j++)
	{

            dma_request(0, (uint32)(buf_ptr + j * S0144_WIDTH), 0x58020000, S0144_WIDTH, 
                                     1, 0);
		
	}
#else
	for(i=0; i<(S0144_WIDTH *S0144_HEIGHT); i++)
	{    
		//value=*buf_ptr++;
		S0144_SEND_DATA(*buf_ptr);
		S0144_SEND_DATA((*buf_ptr++)<<8 );
	}
#endif


#else
	SCI_TRACE_LOW("tft_S0144.c S0144_Invalidate line%d", __LINE__);
	
	address = (uint16) ( (((S0144_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));	
	S0144_sendcommand1(0x44, address);		// set horizon address


	address = (uint16) ( ((S0144_HEIGHT-1) & 0xFF) << 8 );
	S0144_sendcommand1(0x45, address);	// set vertical address

	// Set start RAM address (AC register)	
	S0144_sendcommand1(0x21, OFFSET_X);	
	S0144_SEND_COMMAND(0x0022); 			// send data.
	
	for(i=0; i<(S0144_WIDTH * S0144_HEIGHT); i++)
		S0144_SEND_DATA( *buf_ptr++ );
		
#endif
	 if(udisk_plugin)
	 	SetAIT701_ByPassMode(0);
	return ERR_LCD_NONE;
}

/*****************************************************************************/
//  Description:    Get the lcd base information..
//	Global resource dependence: 
//  Author:         louis.wei
//	Note:
/*****************************************************************************/
LOCAL  ERR_LCD_E   S0144_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		= S0144_WIDTH;
	lcd_info_ptr->lcd_height	= S0144_HEIGHT;
	lcd_info_ptr->lcdbuff_ptr	= (void *)LCD_GetLCDBuffer();
		
	return ERR_LCD_NONE;
}

/******************************************************************************/
//  Description:   Set the windows address to display, in this windows
//                 color is  refreshed.
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
__inline void S0144_set_display_window(
	uint8 left, 	// start Horizon address
	uint8 top, 		// start Vertical address
	uint8 right, 	// end Horizon address
	uint8 bottom	// end Vertical address
	)
{
	uint16 address = 0;
#ifndef DATA_8BIT
	address = (uint16) ((((right & 0xFF) + OFFSET_X)<<8) | ((left & 0xFF) + OFFSET_X));
	S0144_sendcommand1(0x44, address);		// set horizon address
	address = (uint16) (((bottom & 0xFF)<<8) | (top & 0xFF));
	S0144_sendcommand1(0x45, address);	// set vertical address
#else
	address = (uint16) ((((right & 0xFF) + OFFSET_X)<<8) | ((left & 0xFF) + OFFSET_X));
	S0144_SEND_COMMAND(0x4400);		// set horizon address
	S0144_SEND_DATA(address);		// set horizon address
	S0144_SEND_DATA(address<<8);		// set horizon address

	address = (uint16) (((bottom & 0xFF)<<8) | (top & 0xFF));
	S0144_SEND_COMMAND(0x4500);		// set vertical address
	S0144_SEND_DATA(address);		// set vertical address
	S0144_SEND_DATA(address<<8);		// set vertical address

#endif
}


/******************************************************************************/
//  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 S0144_set_start_address(
	uint8 left, 
	uint8 top
	)
{
	uint16 address = 0;
		
	address = (uint16) (((top & 0xFF)<<8) | ((left & 0xFF) + OFFSET_X));
#ifndef DATA_8BIT
	S0144_sendcommand1(0x21, address);	// Set start RAM address (AC register)
#else
	S0144_SEND_COMMAND(0x2100);
	S0144_SEND_DATA(address);
	S0144_SEND_DATA(address<<8);
#endif
}

/******************************************************************************/
//  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 S0144_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(udisk_plugin)
	{
	 	SetAIT701_ByPassMode(1);
	}
	else
	{
		if (LCD_GetRefreshFlag() != TRUE )
		{
		      SCI_TRACE_LOW(" LCD_GetRefreshFlag");
			return ERR_LCD_OPERATE_FAIL ;
		}
	}
	
    //SCI_TRACE_LOW("tft_S0144.c S0144_InvalidateRect line%d: left = %d, top = %d, right = %d, bottom = %d", __LINE__, left, top, right,bottom);
  	left 	= (left >= S0144_WIDTH)    ? S0144_WIDTH-1 : left;
	right 	= (right >= S0144_WIDTH)   ? S0144_WIDTH-1 : right;
	top 	= (top >= S0144_HEIGHT)    ? S0144_HEIGHT-1 : top;
	bottom 	= (bottom >= S0144_HEIGHT) ? S0144_HEIGHT-1 : bottom;

	if ( ( right < left ) || ( bottom < top ) )
	{
		return ERR_LCD_PARAMETER_WRONG;
	}
 
 	 	
	S0144_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 		
#ifndef DATA_8BIT
	S0144_set_start_address(left, top);

	S0144_SEND_COMMAND(0x22); 			// send data.
       rect_width = right-left+1;
       
	for (j = top; j <= bottom; j++)
	{	

            dma_request(0, (uint32)(buf_ptr + j * S0144_WIDTH+left), 0x58020000, rect_width, 
                    1, 0);	
	
	}
#else

	S0144_set_start_address(left, top);

	S0144_SEND_COMMAND(0x2200); 			// send data.

	for (i = top; i <= bottom; i++)	
	{				
		for (j = left; j <= right; j++)	// real write 
		{

			S0144_SEND_DATA( *(buf_ptr + i*S0144_WIDTH + j) );
			S0144_SEND_DATA( *(buf_ptr + i*S0144_WIDTH + j)<<8 );
		}
	}		

#endif
#else

	row = bottom - top;
	column = right - left;

	S0144_set_start_address(left - dummy_before, top);

	S0144_SEND_COMMAND(0x22); 			// send data.

	for (i = 0; i <= row; i++)
	{	
		for(j = 0; j<dummy_before; j++) // Insert dummy write befor real write.
			S0144_SEND_DATA(0x00);
			
		for (j = 0; j <= column; j++)	// real write 
			S0144_SEND_DATA( *(buf_ptr + (top+i)*S0144_WIDTH + left+j) );
	
		for(j=0; j<dummy_after; j++)	// Insert dummy write after real write.
			S0144_SEND_DATA(0x00);
	}			
#endif
	if(udisk_plugin)
		SetAIT701_ByPassMode(0);
	return ERR_LCD_NONE;
}

/******************************************************************************/
//  Description:  for mp4 display
//	Global resource dependence: 
//  Author:  juan.zhang

/******************************************************************************/
LOCAL ERR_LCD_E S0144_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
	)
{
	uint32 i, j;
	uint32 dummy_before, dummy_after;
	uint32 row, column,rect_width;

  	left 	= (left >= 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_S0144.c S0144_InvalidateRectImage() left=%d,right=%d,top=%d,bottom=%d,is_invert=%d line%d", left,right,top,bottom,is_invert,__LINE__); 	
 #ifndef DATA_8BIT	
 	if (is_invert)
	{
		S0144_sendcommand1(0x0003,0x0028 );//Qlw 2006/12/06
	}
	else
	{
		S0144_sendcommand1(0x0003,0x0030 );//Qlw 2006/12/06
	}
#else
 	if (is_invert)
	{
		S0144_SEND_COMMAND(0x0300 );//Qlw 2006/12/06
		S0144_SEND_DATA(0x0000);
		S0144_SEND_DATA(0x2800);
	}
	else
	{
		S0144_SEND_COMMAND(0x0300 );//Qlw 2006/12/06
		S0144_SEND_DATA(0x0000);
		S0144_SEND_DATA(0x3000);
	}
#endif 	 	
	S0144_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.
	

 #ifndef DATA_8BIT		
	//	S0144_set_display_window(left, top, right, bottom);	
	if (is_invert)
	{
		S0144_set_start_address(right, top);
	}	    
	else
	{
		S0144_set_start_address(left, top);
	}    

	S0144_SEND_COMMAND(0x22); 			// send data.

	if (is_invert)
	{
		for (j = left; j <= right; j++)
		{		
			for (i = top; i <= bottom; i++)
			{
				S0144_SEND_DATA( *(buf_ptr + j * 176 + i) ); 
			}
		}			
	}
	else
	{
		for (j = top; j <= bottom; j++)
		{
			for (i = left; i <= right; i++)
			{
				S0144_SEND_DATA( *(buf_ptr + j * 176 + i) );
			}
		}				
	}	

	S0144_sendcommand1(0x0003,0x0030 );//Qlw 2006/12/06

#else
	//	S0144_set_display_window(left, top, right, bottom);	
	if (is_invert)
	{
		S0144_set_start_address(right, top);
	}	    
	else
	{
		S0144_set_start_address(left, top);
	}    

	S0144_SEND_COMMAND(0x2200); 			// send data.

	if (is_invert)
	{
		for (j = left; j <= right; j++)
		{		

⌨️ 快捷键说明

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