?? lcd.c
字號(hào):
void lcd_clean(unsigned char start_seg,unsigned char end_seg,unsigned char start_page,unsigned char end_page)
{
unsigned char i=0,j=0;
//clear screen
for(j=start_page;j<end_page+1;j++)
{
//lcd_data(0x00);
lcd_ins(0xb0+j);
lcd_ins(0x00+(start_seg&0x0f));
lcd_ins(0x10+((start_seg&0xf0)>>4));
for(i=0;i<end_seg;i++)
{
lcd_data(0x00);
}
}
}
void lcd_ins(unsigned char ins)
{//WD
REG32(GPDR) &= ~0x00001000;
//A0
REG32(GPDR) &= ~0x00000400;
//cs
// REG32(GPDR) &= ~0x00200000;
//RD
REG32(GPDR) |= 0x00000800;
//for(i=0;i<8;i++)
//{
// set_io_output(i);//set d4-d7 can be read
//}
REG32_GPDR &= 0xffffff00;
REG32_GPDR |= ins;
//RD
REG32(GPDR) &= ~0x00000800;
//cs->h
// REG32(GPDR) |= 0x00200000;
//A0
REG32(GPDR) |= 0x00000400;
//WD
REG32(GPDR) |= 0x00001000;
}
void lcd_data(unsigned char data)
{//WD
REG32(GPDR) &= ~0x00001000;
//A0
REG32(GPDR) |= 0x00000400;
//cs
// REG32(GPDR) &= ~0x00200000;
//RD
REG32(GPDR) |= 0x00000800;
//for(i=0;i<8;i++)
//{
// set_io_output(i);//set d4-d7 can be read
//}
REG32_GPDR &= 0xffffff00;
REG32_GPDR |= data;
//RD
REG32(GPDR) &= ~0x00000800;
//cs->h
// REG32(GPDR) |= 0x00200000;
//A0
REG32(GPDR) &= ~0x00000400;
//WD
REG32(GPDR) |= 0x00001000;
}
void lcd_dis_init()
{
unsigned char i,j; //0x24 0x34 //0xc8
unsigned char buf[15] = {0xa1,0xB0,0xa2,0x2F,0x23,0x81,0x37,0x10,0x00,0xA6,0xAF,0XC8,0xF8,0x00,0xa5};
//CS GPIO 21
REG32(GPAUR) &= 0xfffff3ff;
REG32(GPDIR) |= 0x00200000;
//RST GPIO 13
REG32(GPALR) &= 0xf3ffffff;
REG32(GPDIR) |= 0x00002000;
//A0 GPIO 10
REG32(GPALR) &= 0xffcfffff;
REG32(GPDIR) |= 0x00000400;
//WR GPIO 12
REG32(GPALR) &= 0xfcffffff;
REG32(GPDIR) |= 0x00001000;
//RD GPIO 11
REG32(GPALR) &= 0xff3fffff;
REG32(GPDIR) |= 0x00000800;
// set up DB[0:7] func 1
REG32(GPALR) &= 0xFFFF0000;
REG32(GPDIR) |= 0x000000ff;
//CS -> L
REG32(GPDR) &= ~0x00200000;
for(j=0;j<14;j++)
{
lcd_ins(buf[j]);
}
//lcd_clean(132);
}
void lcdini()
{
unsigned char i,j; //0x24 0x34 //0xc8
unsigned char buf[15] = {0xa1,0xB0,0xa2,0x2F,0x23,0x81,0x37,0x10,0x00,0xA6,0xAF,0XC8,0xF8,0x00,0xa5};
//CS GPIO 21
REG32(GPAUR) &= 0xfffff3ff;
REG32(GPDIR) |= 0x00200000;
//RST GPIO 13
REG32(GPALR) &= 0xf3ffffff;
REG32(GPDIR) |= 0x00002000;
//A0 GPIO 10
REG32(GPALR) &= 0xffcfffff;
REG32(GPDIR) |= 0x00000400;
//WR GPIO 12
REG32(GPALR) &= 0xfcffffff;
REG32(GPDIR) |= 0x00001000;
//RD GPIO 11
REG32(GPALR) &= 0xff3fffff;
REG32(GPDIR) |= 0x00000800;
// set up DB[0:7] func 1
REG32(GPALR) &= 0xFFFF0000;
REG32(GPDIR) |= 0x000000ff;
//CS -> L
REG32(GPDR) &= ~0x00200000;
//RST -> H
REG32(GPDR) |= 0x00002000;
delayns(60000);
//RST -> L
REG32(GPDR) &= ~0x00002000;
delayns(60000);
//RST -> H
REG32(GPDR) |= 0x00002000;
//while(1);
//delayns(10000);
//while(1)
//{
for(j=0;j<14;j++)
{
lcd_ins(buf[j]);
}
//lcd_clean(132);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -