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

📄 lcd12864.i

📁 该模板使用于周立功公司研发的EasyARM2100系列开发板
💻 I
📖 第 1 页 / 共 2 页
字号:
#line 1 "src\\lcd12864.c"
#line 1 "src\\system.h"










#line 1 "src\\target.h"





























 










extern void Reset(void);
















 

extern void TargetInit(void);


















 





 



 
#line 12 "src\\system.h"

#line 1 "src\\sys_init.h"





extern 	void	init_sys(void);
extern 	void 	init_io(void);
extern 	void 	init_clock(void);
extern 	void 	init_timer0(void);
extern 	void 	init_timer1(void);
extern 	void 	init_int0(void);
extern 	void 	init_int2(void);

#line 14 "src\\system.h"













 
















 




















#line 2 "src\\lcd12864.c"










volatile uint32 key_delay=0;
volatile uint8 key_value=0;
volatile uint8 key_value0=0;

volatile uint8 Bkey_been_down=0;
volatile uint8 temp_value=0;
volatile uint8 Bkey_delay=0;

uint8 data; 
uint8 Bread_key=0;

void lcd_input(void)
{
 IO0DIR = IO0DIR&0xe47fffff;
 IO1DIR = IO1DIR&0xfff1ffff;
}

void lcd_output(void)  
{
 IO0DIR |= IO0DIR|LCD_CS1|LCD_CS2|LCD_RW|LCD_E|LCD_D0|LCD_D2|LCD_D3|LCD_D5|LCD_D7;
 IO1DIR |= IO1DIR|LCD_RS|LCD_D1|LCD_D4|LCD_D6;
}
uint8 Read_Byte(void)
 { 
  uint8 D0,D1,D2,D3,D4,D5,D6,D7,RDAT;
  lcd_input();  

  if((IO0PIN&LCD_D0)>1)         D0=1;
  else                          D0=0;
            
  if((IO1PIN&LCD_D1)>1)         D1=2;
  else                          D1=0;
          
  if((IO0PIN&LCD_D2)>1)         D2=4; 
  else                          D2=0;
               
  if((IO0PIN&LCD_D3)>1)         D3=8; 
  else                          D3=0;
            
  if((IO1PIN&LCD_D4)>1)         D4=16;
  else                          D4=0;
        
  if((IO0PIN&LCD_D5)>1)         D5=32;
  else                          D5=0;
              
  if((IO1PIN&LCD_D6)>1)         D6=64;
  else                          D6=0;           
        
  if((IO0PIN&LCD_D7)>1)         D7=128;
  else                          D7=0;
  RDAT=0;
  RDAT=D0|D1|D2|D3|D4|D5|D6|D7;
  return RDAT;
 }

uint8  Read_LCD(void)
{	    
  uint8 rdata;
      	Busy();
      
    	
        lcd_delay(40);
        IO0SET|=LCD_RS;     			        
        lcd_delay(40);
        IO0SET|=LCD_RW;						
        lcd_delay(40); 
        			
	    IO0SET|=LCD_E;
	    lcd_delay(40);	
        rdata=Read_Byte();
        
	    lcd_delay(40);					
    	IO0CLR|=LCD_E;
    	return rdata;
}  	
void Write_LCDByte(uint8 comd_word)
 {
  if(comd_word&0x01)    IO0SET|=LCD_D0;
  else                  IO0CLR|=LCD_D0;  
            
  if(comd_word&0x02)    IO1SET|=LCD_D1;
  else                  IO1CLR|=LCD_D1;
          
  if(comd_word&0x04)    IO0SET|=LCD_D2;   
  else                  IO0CLR|=LCD_D2;
               
  if(comd_word&0x08)    IO0SET|=LCD_D3;  
  else                  IO0CLR|=LCD_D3;
            
  if(comd_word&0x10)    IO1SET|=LCD_D4;
  else                  IO1CLR|=LCD_D4;
        
  if(comd_word&0x20)    IO0SET|=LCD_D5;
  else                  IO0CLR|=LCD_D5;
              
  if(comd_word&0x40)    IO1SET|=LCD_D6;
  else                  IO1CLR|=LCD_D6;           
        
  if(comd_word&0x80)    IO0SET|=LCD_D7;
  else                  IO0CLR|=LCD_D7;
 }


void lcd_delay(uint8 delay_timer)
{
  uint8 delay_t;
  for(delay_t=0;delay_t<delay_timer;delay_t++);
}

void Busy(void)
{  
 	lcd_output();
  	
	IO1CLR|=LCD_RS;     			        
	lcd_delay(40);
	IO0SET|=LCD_RW;						
	lcd_delay(40);
	Write_LCDByte(0X80);
	IO0DIR=IO0DIR&0xff7fffff;	
		while(1)
	   {
		    IO0SET|=LCD_E;					
		    lcd_delay(25);
			IO0CLR|=LCD_E;					
	    if((IO0PIN&0x00800000)==0)   break;	   				
	   }	
}



void write_LCD_comd0(uint8 comd_word)
{	  
      	Busy();
    	lcd_output();
  	
        lcd_delay(40);
        IO1SET|=LCD_RS; 
        lcd_delay(40);
        IO0CLR|=LCD_RW;   
        lcd_delay(40);       
        Write_LCDByte(comd_word);
        lcd_delay(40);				
	    IO0SET|=LCD_E;	
	    lcd_delay(40);					
    	IO0CLR|=LCD_E;
}  	

void write_LCD_comd1(uint8 d1,uint8 comd_word)
{
        Busy();	
	    lcd_output();
  	
	    lcd_delay(40);
	    IO0CLR|=LCD_RS;	
      	lcd_delay(40);
      	IO0CLR|=LCD_RW;   
        lcd_delay(40);
        Write_LCDByte(comd_word|d1);    
      	lcd_delay(40);
      	IO0SET|=LCD_E;					
    	lcd_delay(40);
    	IO0CLR|=LCD_E;
}


void clr_LCD_screen0(uint8 Bselect_area)
{

  unsigned char i,j;
  if(Bselect_area)
   {
   IO0CLR|=LCD_CS2;
   IO0SET|=LCD_CS1;   
   
   }
  else
   {
   IO0CLR|=LCD_CS1;
   IO0SET|=LCD_CS2;
   
   }
  lcd_delay(40);   
   for (i=0;i<8;i++)         
   {
    write_LCD_comd1(0XB8,i);
	write_LCD_comd1(0X40,0);
    for (j=0;j<64;j++)
      {	 
      write_LCD_comd0(0);  
      }
   }
}

void clr_LCD_screen(void)
{

 clr_LCD_screen0(1);
 clr_LCD_screen0(0);

}  


void init_LCD(void)
{
  IO0SET|=LCD_CS2;
  lcd_delay(40); 
  IO0CLR|=LCD_CS1;
  lcd_delay(40); 
  write_LCD_comd1(0X3F,0);  
  write_LCD_comd1(0XC0,0);
  clr_LCD_screen0(0);
  lcd_delay(40); 
  IO0SET|=LCD_CS1;
  lcd_delay(40); 
  IO0CLR|=LCD_CS2;
  write_LCD_comd1(0X3F,0);  
  write_LCD_comd1(0XC0,0);
  clr_LCD_screen0(1);
}














void show_picture(uint8 const *word_tab,uint8 word_position_x,uint8 word_position_y,uint8 m,uint8 n)
{
  uint8 const *temp_pointer;
  uint8 i,j;
  uint8 Bchange_area;
 
  temp_pointer=word_tab;
  for (i=0;i<n/8;i++)         
   {
    if(word_position_y<64&&word_position_y+m>64)
     Bchange_area=1;
    else
     Bchange_area=0;

    if(word_position_y/64)
     {
      IO0CLR|=LCD_CS2;
      IO0SET|=LCD_CS1;
	
     }
    else
     {
      IO0CLR|=LCD_CS1;
      IO0SET|=LCD_CS2;
	
     }
    lcd_delay(40);
    write_LCD_comd1(0XB8,word_position_x/8+i);
	write_LCD_comd1(0X40,word_position_y%64);
    for (j=0;j<m;j++)
      {
	   if(Bchange_area)
	   {
	    
        if(word_position_y+j>=64)
         {
         
          Bchange_area=0;
	      IO0CLR|=LCD_CS2;
          IO0SET|=LCD_CS1;
		  write_LCD_comd1(0XB8,word_position_x/8+i);
          write_LCD_comd1(0X40,0); 	
	     }
	   }
       write_LCD_comd0(*temp_pointer++);
       
      
      
      
     
     
       
       
      }
   } 
}


void read_test(void)
{ uint8 rdat;
show_dot(0,0);
write_LCD_comd1(0XB8,0);
write_LCD_comd1(0X40,0);
rdat=Read_LCD();
 UART0_SendByte(rdat);

}
void show_picture_n(uint8 const *word_tab,uint8 word_position_x,uint8 word_position_y,uint8 m,uint8 n)
{
  uint8 const *temp_pointer;
  uint8 i,j;
  uint8 Bchange_area;
  temp_pointer=word_tab;
  for (i=0;i<n/8;i++)         
   {
    if(word_position_y<64&&word_position_y+m>64)
     Bchange_area=1;
    else
     Bchange_area=0;
    if(word_position_y/64)
     {
      IO0CLR|=LCD_CS2;
      IO0SET|=LCD_CS1;
	
     }
    else
     {
      IO0CLR|=LCD_CS1;
      IO0SET|=LCD_CS2;
	 }
    lcd_delay(40);
    write_LCD_comd1(0XB8,word_position_x/8+i);
	write_LCD_comd1(0X40,word_position_y%64);
    for (j=0;j<m;j++)
      {
	   if(Bchange_area)
	   {
	    
        if(word_position_y+j>=64)
         {
          Bchange_area=0;
	      IO0CLR|=LCD_CS2;
          IO0SET|=LCD_CS1;
	      lcd_delay(40);
		  write_LCD_comd1(0XB8,word_position_x/8+i);
          write_LCD_comd1(0X40,0); 	
	     }
	   }
       write_LCD_comd0(~(*temp_pointer++)); 
      }
   }
}   

void erase_picture(uint8 word_position_x,uint8 word_position_y,uint8 m,uint8 n)
{
  uint8 i,j;
  uint8 Bchange_area;
  lcd_delay(40); 

  for (i=0;i<n/8;i++)         
   {
    if(word_position_y<64&&word_position_y+m>64)
     Bchange_area=1;
    else
     Bchange_area=0;
    if(word_position_y/64)
     {
      IO0CLR|=LCD_CS2;
      IO0SET|=LCD_CS1;
	
     }
    else
     {
      IO0CLR|=LCD_CS1;
      IO0SET|=LCD_CS2;
	
     }
     lcd_delay(40);
    write_LCD_comd1(0XB8,word_position_x/8+i);
	write_LCD_comd1(0X40,word_position_y%64);

    lcd_delay(10);
     
    for (j=0;j<m+1;j++)
      {
	   if(Bchange_area)
	   {
	    
        if(word_position_y+j>=64)
         {
          Bchange_area=0;
	      IO0CLR|=LCD_CS2;
          IO0SET|=LCD_CS1;
	      lcd_delay(10);
		  write_LCD_comd1(0XB8,word_position_x/8+i);
          write_LCD_comd1(0X40,0); 	
	     }
	   }
       write_LCD_comd0(0); 
      }     
   }
}


void show_dot(uint8 word_position_x,uint8 word_position_y)
{
   if(word_position_y/64)
     {
      IO0CLR|=LCD_CS2;
      IO0SET|=LCD_CS1;
     }
    else
     {
      IO0CLR|=LCD_CS1;

⌨️ 快捷键说明

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