0x00,0x7E,0x10,0x10,0x7E,0x00,/*"H",0*/
/* (6 X 8 , 楷体_GB2312 )*/
0x00,0x7E,0x52,0x52,0x42,0x00,/*"E",1*/
/* (6 X 8 , 楷体_GB2312 )*/
0x42,0x7E,0x42,0x40,0x40,0x00,/*"L",2*/
/* (6 X 8 , 楷体_GB2312 )*/
0x42,0x7E,0x42,0x40,0x40,0x00,/*"L",3*/
/* (6 X 8 , 楷体_GB2312 )*/
0x00,0x3C,0x42,0x42,0x3C,0x00,/*"O",4*/
/* (6 X 8 , 楷体_GB2312 )*/};
LCD_IOInit();
LCD_Init();
//for(i=0;i<30;i++){
//LCD_WriteOneByte(Hello[i]);
//}
LCD_WriteMByte(Hello,30);
LCD_nCS = 1;
:
:
}
下面是采用 SPI 总线方式控制 LCD 显示的例子:
//========================
//This file is applicable to Eshine EXBEE-DK V1
//Function:LCD test,the LCD use SPI BUS.The SPI BUS occupation P1-U
SART1-ALT.2
//InPut
//OutPut
//Created :longfan,2010.1.10
//Modify :
//========================
#include "periodef.h"
#include "font.h"
#include "TestBMP.h"
#include
void delay(uint n){
//26 cycles delay
while(--n)asm("NOP");
}
void LEDInit(){
P1SEL &= 0XFE;
//P1_0 defined General purpose I/O
P1DIR |= 0X01;
DEBUG_LED = 1;
//P1_0 defined Output
//LED light up
}
//========================
//Initial P1-USART1-SPI
void SPIInit_U1_P1(void){
PERCFG |= 0X02;
P1SEL |= 0XE0;
P2SEL |= 0X40;
U1GCR |= 0x20;
//USART1.alt.2,P1
//P1,ISP,P1_4(LCD_DnC) defined general IO
//USART1 has priority
//MSB first,Negative clock polarity,Data is output
on MOSI on the falling edge of CLK
U1GCR |= 19;
U1BAUD = 0;
UTX1IF = 0;
//MAX Baud rate(17),falling edge
//Clear interrupt
}
//========================
//P1-USART1-SPI Send One Byte
void SPI_SendOne_U1_P1(uchar data){
U1DBUF = data;
while(!UTX1IF);
UTX1IF = 0;
}
//========================
//P1-USART1-SPI Send Multily Byte
void SPI_Send_U1_P1(uchar *data,uint length){
while(length){
SPI_SendOne_U1_P1(*data);
data++;
length -= 1;
}
}
//========================
//LCD Use SPI BUS,Set the first display piex.
//When after call this function can direct call SPI data output function
//0
SPI_SendOne_U1_P1(0x40 | Y);
LCD_DnC = 1;
}
//========================
//LCD Use SPI BUS,Clear the LCD Display and its RAM.
void SPI_ClearLCD(){
uint i;
SPI_LCDSetPos(0,0);
for (i=0; i<504; i++){
SPI_SendOne_U1_P1(0);
}
}
//========================
//LCD Use SPI BUS,Send one LCD Command
void SPI_LCDWriteOneComm(uchar command){
LCD_DnC = 0;
SPI_SendOne_U1_P1(command);
}
//========================
//LCD Use SPI BUS,Send More than one LCD Command
void SPI_LCDWriteMulComm(uchar *command,uchar num){
LCD_DnC = 0;
SPI_Send_U1_P1(command,num);
}
//========================
//LCD Use SPI BUS,Send More than one data
void SPI_LCDWriteData(uchar *data,uchar length){
LCD_DnC = 1;
SPI_Send_U1_P1(data,length);
}
//========================
//LCD Use SPI BUS,Display a english character Without set position,The
inverse argument control
//the inverse video mode.When use font library call this function to displa
y.
//InPut
//
//OutPut
:character:The character want to display
inverse :Inverse video mode(1) or not(0)
:
//Created :longfan,2010.1.10
//Modify :
//========================
void SPI_LCDWriteChar(uchar character,uchar inverse){
uchar line;
LCD_DnC = 1;
if(inverse){
for(line=0;line<6;line++){
SPI_SendOne_U1_P1(~font6x8[character-32][line]);
}
}else{
SPI_Send_U1_P1((uchar *)font6x8[character-32],6);
}
}
//========================
//LCD Use SPI BUS,Display a english character at (X,Y),The inverse arg
ument control
//the inverse video mode.When use font library call this function to displa
y.
//InPut
//
//
//OutPut
//Created :longfan,2010.1.10
//Modify :
//========================
void SPI_LCDDISPChar(uchar character,uchar X,uchar Y,uchar inverse){
:character:The character want to display
X,Y
inverse :Inverse video mode(1) or not(0)
:The position want to display
:
uchar line;
SPI_LCDSetPos(X,Y);
if(inverse){
for(line=0;line<6;line++){
SPI_SendOne_U1_P1(~font6x8[character-32][line]);
}
}else{
SPI_Send_U1_P1((uchar *)font6x8[character-32],6);
}
}
//========================