LCD5110液晶屏原是一款用于手机的显示屏,将它与M471开发板所配置的Arduino接口相配合,无需连线即可直接实现显示功能,其显示效果如图1所示。 图1 显示效果 该显示屏与开发板的连接关系为: 1.VCC---VREF 2.GND---VSS 3.SCE---PA2 4.RST--- PA1 5.D/C--- PA0 6.SDIN--- PA3 7.SCLK--- PA4 8.LED+--- PA5 图2 Arduino接口 为实现LCD5110屏的显示驱动,其引脚的配置函数为: void LCD_GPIO_Cogfig(void)
{
GPIO_SetMode(PA, BIT5, GPIO_MODE_OUTPUT);
GPIO_SetMode(PA, BIT4, GPIO_MODE_OUTPUT);
GPIO_SetMode(PA, BIT3, GPIO_MODE_OUTPUT);
GPIO_SetMode(PA, BIT2, GPIO_MODE_OUTPUT);
GPIO_SetMode(PA, BIT1, GPIO_MODE_OUTPUT);
GPIO_SetMode(PA, BIT0, GPIO_MODE_OUTPUT);
PA5=1;
PA2=0;
}
相应的以I/O口模拟SPI接口发送数据的函数为: void LCD_write_byte(unsigned char wbyte, unsigned char dat_cmd)
{
unsigned char i;
if(dat_cmd)
{
PA0=1;
}
else
{
PA0=0;
}
for(i = 8; i; i--)
{
if(wbyte & 0x80)
{
PA3=1;
}
else
{
PA3=0;
}
PA4=0;
wbyte <<= 1;
TIMER_Delay(TIMER0, 1);
PA4=1;
}
}
LCD5110屏的初始化函数为: void LCD5510_Init(void)
{
LCD_GPIO_Cogfig();
TIMER_Delay(TIMER0, 800000);//mdelay(800);
PA1=0;
TIMER_Delay(TIMER0, 2);
PA1=1;
LCD_write_cmd(0x21);
LCD_write_cmd(0x06);
LCD_write_cmd(0x13);
LCD_write_cmd(0xc8);
LCD_write_cmd(0x20);
LCD_write_cmd(0x0c);
LCD_write_cmd(Y_Page_Addr);
LCD_write_cmd(X_Col_Addr);
LCD_clr_scr();
}
实现清屏的函数为: void LCD_clr_scr(void)
{
unsigned int i;
LCD_write_cmd(X_Col_Addr);
LCD_write_cmd(Y_Page_Addr);
for(i = 504; i; i--) LCD_write_dat(0x00);
}
实现字符串显示的函数为: void LCD_prints(unsigned char x, unsigned char y, unsigned char *s_dat)
{
while(*s_dat && x < 10)
{
LCD_printc(x++, y, *s_dat);
s_dat++;
}
}
而实现显示效果的主程序则是: int main()
{
SYS_Init();
GPIO_SetMode(PB, BIT14, GPIO_MODE_OUTPUT);
GPIO_SetMode(PH, BIT4, GPIO_MODE_INPUT);
PB14 = 1;
LCD5510_Init();
LCD_prints(0,0,"M471 TEST");
LCD_prints(0,1,"LCD5510 ");
LCD_prints(0,2,"jinglixixi");
while(1)
{
PB14 = 0;
TIMER_Delay(TIMER0, 500000);
PB14 = 1;
TIMER_Delay(TIMER0, 500000);
}
}
有了LCD5110屏的显示驱动函数,再有信息显示或数据显示的任务交由它就可以了。
|