📄 main.c
字号:
#include"LPC2124.h"
#include"config.h"
void writecmd(uint8 cmd,uint8 busyc);
void writedata(uint8 dat);
void display1(uint8 *str1);
void display2(uint8 *str2);
void display3(uint8 key);
void delay1(uint32 count);
void lcdinit(void);
void systeminit(void);
#define RS 0x00000100;
#define RW 0x00000200;
#define E 0x00001000;
unsigned char str11[]={"I Love You"};
unsigned char str22[]={"MM"};
int main(void)
{
systeminit();
lcdinit();
display1(str11);
display2(str22);
while(1) ;
}
void systeminit(void)
{
PINSEL0=0x00000000;
PINSEL1=0x00000000;
IO0DIR=0x000013ff;
}
void lcdinit(void)
{
// delay(800); //可要可不要
// writecmd(0x38,0);
// delay(400);
// writecmd(0x38,0);
// delay(400);
// writecmd(0x38,0);
// delay(400);
writecmd(0x38,1);
writecmd(0x08,1);
writecmd(0x01,1);
writecmd(0x06,1);
writecmd(0x0c,1);
}
void display1(uint8 *str1)
{
uint8 x=0;
while(*str1 !='\0')
{
x|=0x80;
writecmd(x,1);
writedata(*str1);
++str1;
++x;
}
}
void display2(uint8 *str2)
{
uint8 y=0;
while(*str2!='\0')
{
y|=0xc0;
writecmd(y,1);
writedata(*str2);
++str2;
y++;
}
}
void delay1(uint32 count)
{
unsigned long i;
for(i=0;i<count;i++);
}
void writecmd(uint8 cmd,uint8 busyc)
{
IO0CLR=E;
IO0CLR=0xff;
IO0SET=cmd;
IO0CLR=RS;
IO0CLR=RW;
IO0SET=E;
delay1(4000);
IO0CLR=E;
if(busyc)
{
IO0DIR=0x001300;
do
{
delay1(4000);
IO0CLR=RS;
IO0SET=RW;
IO0SET=E;
delay1(4000);
IO0CLR=E;
}
while(IO0PIN & 0x00000080!=0);
IO0DIR=0x0013FF;
}
}
void writedata(unsigned char dat)
{
IO0CLR=E;
IO0CLR=0xff;
IO0SET=dat;
IO0SET=RS;
IO0CLR=RW;
IO0SET=E;
delay1(4000);
IO0CLR=E;
IO0DIR=0x00001300;
do
{
delay1(4000);
IO0CLR=RS;
IO0SET=RW;
IO0SET=E;
delay1(4000);
IO0CLR=E;
}
while(IO0PIN & 0x00000080!=0);
IO0DIR=0x000013FF;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -