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

📄 lcd_1289_8312.c

📁 当前流行的屏驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
		*/
		WriteCommand(0x3B01);
		Delay(40);
		
		WriteCommand(0x0020);
     }  
	 
}

/*---- LCD final ----*/ 
INT32 LcdFina()
{
	// Step1: nPWDN = 0
	
	// Step2: VDD2.8 Power OFF
	//config PA1 for LED_ON  
	GPIO_SetOutput(GPIO_PORTA, 0, BIT1);
	
	
	return 0;
}

/**************************************************************************************/
/************************      LCD APP function      **********************************/
/**************************************************************************************/ 
//open the LCD      
INT32 lcd_Open(BOOL enableIrq) //need modify
{
	if(FLAG_LCD == 0)
	{
		DMACTL dmactl;
		volatile UINT32 *pBUCR4 = (volatile UINT32 *)0x00209198;
		dmactl.channel = CHANNEL4_LCD_TX;
		dmactl.priority = PRIORITY;
		if(enableIrq == TRUE)
		{
			dmactl.isintenable = INTENABLE;
		}
		else
		{
			dmactl.isintenable = INTDISABLE;
		}
		dmactl.mdir = INCREASE;
		dmactl.srcmode = LINEAR;
		dmactl.dstmode = LINEAR;
		dmactl.srcsize = D32;
		dmactl.dstsize = D32;
		dmactl.burstlen = 32;  //change by huangwei
		dmactl.reqsrc = REQ_EXDMA;	
		
		InitCS0();
		LcdInit();	
		DMAChannel_Open(&dmactl);  
		*pBUCR4 = 80;
	}
	
	FLAG_LCD++;	  
	
	return 0;  
}




/************************************************************
Parameter :	topLeftX : the coordinate of x 

  topLeftY : the coordinate of x
  
	width: the width of picture window
	height: the height of picture window
	
	  *picBuf: the point of picture
	  
		note:  topLeftX+width<=220
		topLeftY+height<=176
		
************************************************************/


INT32 lcd_Write(INT16 topLeftX, INT16 topLeftY, INT16 width, INT16 height, UINT16 *picBuf)
{
	int i;
	int lcdInterface;
	int len;
	UINT16 * temp_picBuf;
	UINT16 tmp0,tmp1,tmp2,tmp3;
	DMACTL dmactl;
	
	
	if(((chip_id)&0xff)==0x89)
	{
		/* CS1 repair*/
        	regEMI->CS0U = 0x00000600;
		regEMI->CS0L =0x44441D01;
		SetLCDWindows(topLeftY,topLeftY+height-1,topLeftX,topLeftX+width-1);     
	//	WriteCommand(0x0021);
		WriteCommand(0x0022);
	} 
	else
	{
		/* CS1 repair*/
		regEMI->CS0U = 0x00000b00;
		regEMI->CS0L = 0x55550D01;	
        SetLCDWindows(topLeftY,topLeftY+height-1,topLeftX,topLeftX+width-1);	
	}
	
	
	GPIO_SetOutput(LCD_RS_PORT, 1<<LCD_RS_BIT, 0);
	
	lcdInterface = (int)0x10000000;
	
	/**/
	len = width * 1;
	i = len - len%16;
	
	//zzy add on 20060605当显示的行数为0时程序会执行相当多次
	if(i<=0)
	{
		return 1;
	}
	
	temp_picBuf = picBuf + width * (height-1);
	
		  __asm
		  {
loop_lwrite:
		  ldrh tmp0, [temp_picBuf], #2
			  ldrh tmp1, [temp_picBuf], #2
			  strh tmp0, [lcdInterface, #4]
			  ldrh tmp2, [temp_picBuf], #2
			  strh tmp1, [lcdInterface, #4]
			  ldrh tmp3, [temp_picBuf], #2	
			  strh tmp2, [lcdInterface, #4]
			  
			  ldrh tmp0, [temp_picBuf], #2
			  strh tmp3, [lcdInterface, #4]
			  ldrh tmp1, [temp_picBuf], #2
			  strh tmp0, [lcdInterface, #4]
			  ldrh tmp2, [temp_picBuf], #2
			  strh tmp1, [lcdInterface, #4]
			  ldrh tmp3, [temp_picBuf], #2
			  strh tmp2, [lcdInterface, #4]
			  
			  ldrh tmp0, [temp_picBuf], #2
			  strh tmp3, [lcdInterface, #4]
			  ldrh tmp1, [temp_picBuf], #2
			  strh tmp0, [lcdInterface, #4]
			  ldrh tmp2, [temp_picBuf], #2
			  strh tmp1, [lcdInterface, #4]
			  ldrh tmp3, [temp_picBuf], #2
			  strh tmp2, [lcdInterface, #4]
			  
			  ldrh tmp0, [temp_picBuf], #2
			  strh tmp3, [lcdInterface, #4]
			  ldrh tmp1, [temp_picBuf], #2
			  strh tmp0, [lcdInterface, #4]
			  ldrh tmp2, [temp_picBuf], #2
			  strh tmp1, [lcdInterface, #4]
			  ldrh tmp3, [temp_picBuf], #2
			  strh tmp2, [lcdInterface, #4]
			  
			  subs i, i, 16
			  strh tmp3, [lcdInterface, #4]
			  bne	loop_lwrite
		  }
		  
		  
		  
		  
		  len=width*(height-1)*2;
		  dmactl.channel = CHANNEL4_LCD_TX;
		  dmactl.srcaddr = (UINT32)picBuf;
		  dmactl.dstaddr = (UINT32)EXT_CHIP_DATA_ADDR;
		  dmactl.len= len;
		  
		  if(len <= LCD_BUFFER_MAXSIZE)
		  {
			  MMU_CleanDCacheMVA((UINT32)picBuf,(UINT32)(picBuf+76800-320));
			  if(DMA_Start(&dmactl))
				  return 0;
		  }
		  return 1;
		  

}


INT32 LCD_Clean(VOID)
{
	INT32 i;
	UINT16 Clean_Buf[76800];
	for(i=0;i<76800;i++)
	{
		Clean_Buf[i] = 0x0000;
	}
	LCD_Write(0,0,320,240,Clean_Buf);
	return 0;
}




/************************************************************
Parameter :	topLeftX : the coordinate of x 

  topLeftY : the coordinate of x
  
	width: the width of window you want to clear
	height: the height of window you want to clear
	
	  ColorValue: the color you want to set in the claer window
	  note:  topLeftX+width<=220
	  topLeftY+height<=176
************************************************************/
INT32 WindowScreenClear(INT16 topLeftX, INT16 topLeftY, INT16 width, INT16 height, UINT16 ColorValue)
{
	int i,j;
	int len;
	
    /* CS1 repair*/
	if(((chip_id)&0xff)==0x89) 
	{
		/* CS1 repair*/
//		regEMI->CS0U = 0x00000600;
//		regEMI->CS0L = 0x44442D01;
		
		SetLCDWindows(topLeftY,topLeftY+height-1,topLeftX,topLeftX+width-1);
		
//		WriteCommand(0x0021);
		WriteCommand(0x0022);
		
		len=width*height;	
	}
	else
	{
		/* CS1 repair*/
		regEMI->CS0U = 0x00000800;
		regEMI->CS0L = 0x00000D01;
		SetLCDWindows(topLeftY,topLeftY+height-1,topLeftX,topLeftX+width-1);
		len=width*height;
	}
	GPIO_SetOutput(LCD_RS_PORT, 1<<LCD_RS_BIT, 0);
	
	
	for(i=0;i<height;i++)
	{
		for(j=0;j<width;j++)
		{
			(*EXT_CHIP_DATA_ADDR) = ColorValue;
		}
	}
	
	return len;
	
}


INT32 LCD_Close(void)
{
	
	FLAG_LCD--;
	if(FLAG_LCD == 0)
	{
		DMACTL dmactl;
		dmactl.channel = CHANNEL4_LCD_TX;
		WindowScreenClear(0, 0, 320, 240, 0xffff);		
		LcdFina();
		DMA_Stop(&dmactl);
	}
	return 0;                     
}

/*********** lcd IO control ******************/

INT32 LCD_Ioctl(INT32 cmd, INT32 para, void *buf)
{	
	switch(cmd)
	{
	case GET_LCD_INFO:
		{
			LCD_INFO *lcd_info = (LCD_INFO *)buf;
			lcd_info->LCD_WIDTH = LCD_PHY_PIXEL_CX;
			lcd_info->LCD_HEIGHT = LCD_PHY_PIXEL_CY;
			lcd_info->LCD_BITS_PER_PIXEL = LCD_PIXEL_BITS;
			lcd_info->LCD_PIXEL_PALETTE = LCD_PIXEL_RGB;
			break;
		}
		
	case LCD_BACKLIGHT_DOWN:
		{
			if(BACK_LIGHT_VALUE <= 0)
			{
				BACK_LIGHT_VALUE = 0;
			}
			else
			{
				BACK_LIGHT_VALUE -= BACK_LIGHT_UNIT;	
			}
			pwm_set_backlight(BACK_LIGHT_VALUE);
			break;
		}
		
	case LCD_BACKLIGHT_UP:
		{
			if(BACK_LIGHT_VALUE >= BACK_LIGHT_MAX_VALUE)
				BACK_LIGHT_VALUE = BACK_LIGHT_MAX_VALUE;
			else
				BACK_LIGHT_VALUE += BACK_LIGHT_UNIT;
			
			pwm_set_backlight(BACK_LIGHT_VALUE);
			break;
			
		}
		
	case LCD_BACKLIGHT_ENABLE:
		{
            pwm_set_backlight(BACK_LIGHT_VALUE);
			break;
		}
		
	case LCD_BACKLIGHT_DISABLE:
		{
			pwm_set_backlight(0);
			break;
		}
		
	case CLEAN_SCREEN:
		{
			LCD_Clean();
			break;
		}
		
	default:
		return -1;
	}
	
	
	return 0;
}

⌨️ 快捷键说明

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