|
#include<avr/io.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
#define uchar unsigned char
#define uint unsigned int
#define RS_0 PORTC &= ~(1 << PC0) //RS为0
#define RS_1 PORTC |= (1 << PC0) //RS为1
#define RW_0 PORTC &= ~(1 << PC1) //RW为0
#define RW_1 PORTC |= (1 << PC1) //RW为1
#define EN_0 PORTC &= ~(1 << PC2) //EN为0
#define EN_1 PORTC |= (1 << PC2) //EN为1
#define PSB_0 PORTC &= ~(1 << PC3) //PSB为0
#define PSB_1 PORTC |= (1 << PC3) //PSB为1
//串/并方式控制,高电平为并行方式,低电平为串行方式
#define RST_0 PORTC &= ~(1 << PC5) //RST为0
#define RST_1 PORTC |= (1 << PC5) //RST为1
uchar Line1_data[]={"wwww"};
uchar Line2_data[]={"wwww"};
uchar Line3_data[]={"wwww"};
uchar Line4_data[]={"wwww"};
void delay_us(unsigned int n)
{
if(n == 0)
return ;
while(--n);
}
void Delay_ms(uint xms)
{
int i,j;
for(i =0;i<xms;i++)
{
for(j=0;j<1140;j++);
}
}
uchar lcd_busy()
{
uchar result;
DDRA = 0x00;
RS_0;
RW_1;
EN_1;
delay_us(40);
result=PIND&0x80;
EN_0;
return result;
}
void lcd_wcmd(uchar cmd)
{
DDRA=0XFF;
RS_0;
RW_0;
EN_0;
PORTA=cmd;
delay_us(40);
EN_1;
delay_us(40);
EN_0;
}
void lcd_wdat(dat)
{
DDRA=0XFF;
RS_1;
RW_0;
EN_0;
PORTA=dat;
delay_us(40);
EN_1;
delay_us(40);
EN_0;
}
void lcd_clr()
{
lcd_wcmd(0x01);
Delay_ms(5);
}
void lcd_init()
{
PSB_1;
RST_0;
Delay_ms(3);
RST_1;
Delay_ms(3);
lcd_wcmd(0x34);
Delay_ms(5);
lcd_wcmd(0x30);
Delay_ms(5);
lcd_wcmd(0x0c);
Delay_ms(5);
lcd_wcmd(0x01);
Delay_ms(5);
}
void LocateXY(uchar x,uchar y)
{
if(y==0){lcd_wcmd(0x80 + x);}
else if(y==1){lcd_wcmd(0x90 + x);}
else if(y==2){lcd_wcmd(0x88 + x);}
else if(y==3){lcd_wcmd(0x98 + x);}
}
void LCD_write_str(uchar x, uchar y,uchar *s)
{
LocateXY(x,y);
while(*s)
{
lcd_wdat(*s);
s++;
}
}
void port_init(void)
{
PORTA = 0XFF;
DDRA = 0XFF;
PORTC=0XFF;
DDRC =0XFF;
}
void main()
{
uchar i;
uchar Line1_data[]={"wwww"};
uchar Line2_data[]={"wwww"};
uchar Line3_data[]={"wwww"};
uchar Line4_data[]={"wwww"};
port_init();
Delay_ms(100);
lcd_init();
while(1)
{
LocateXY(0,0);
for(i=0;i<16;i++)
{
lcd_wdat(Linel_data[i]);
Delay_ms(100);
}
LocateXY(0,1);
for(i=0;i<16;i++)
{
lcd_wdat(Line2_data[i]);
Delay_ms(100);
}
LocateXY(0,2);
for(i=0;i<16;i++)
{
lcd_wdat(Line3_data[i]);
Delay_ms(100);
}
LocateXY(0,3);
for(i=0;i<16;i++)
{
lcd_wdat(Line4_data[i]);
Delay_ms(100);
}
lcd_clr();
}
}
main.c:134: error: 'Linel_data' undeclared (first use in this function)
main.c:134: error: (Each undeclared identifier is reported only once
main.c:134: error: for each function it appears in.)
不知道怎么回事
帮帮忙啊 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|