?? st7565.c
字號:
//*************************************************************************
//LCM parallel mode
//
//
//
//************************************************************************
#include "chip.h"
#include "st7565.h"
#include "lcdm.h"
void LCDMdelay(unsigned int i)
{
while(i--);
}
void InitLCMDPhy(void)
{
LCDM_DPORT_SEL;
LCDM_DPORT_IN; //d0-d7 input direction
LCDM_CPORT_SEL;
LCDM_INIT_STAT; //setting CS,A0,Wr,Rd and Rst status
LCDM_CPORT_DIR; //output CS,A0,Wr,Rd and Rst status to pin
LCDM_RST_SEL;
RST_SEL;
RST_DIR;
RST_ASSERT; //RST low
}
void SwapOrder(unsigned char *c)
{
unsigned char temp,i;
for(temp=0,i=0;i<8;i++)
{
temp>>=1;
if(*c & 0x80) temp |=0x80;
*c<<=1;
}
*c=temp;
}
void WrLCMComd(unsigned char cmd) //for LCM parallel(8080mode)
{
while(RdLCMStatus() & BUSY_STAT);
LCDM_COMD; //LCM command register selected
CS_ENABLE; //chip selection enable
WR_LOW; //launch WR signal
LCDM_DPORT_OUT; //switching data port to output
SwapOrder(&cmd);
LCDM_DAT_OUT=cmd; //put the command to bus
__no_operation(); //waiting data stable
WR_HIGH; //latching command into LCM register
LCDM_INIT_STAT; //isuusing LCM controlling idle status
LCDM_DPORT_IN;
}
void WrLCMData(unsigned char cdata) //for LCM parallel(8080mode)
{
while(RdLCMStatus() & BUSY_STAT);
LCDM_DATA; //LCM DDRAM register selected
CS_ENABLE; //chip selection enable
WR_LOW; //launch WR signal
SwapOrder(&cdata);
LCDM_DPORT_OUT; //switching data port to output
LCDM_DAT_OUT=cdata; //put the command to bus
__no_operation(); //waiting data stable
WR_HIGH; //latching command into LCM register
LCDM_INIT_STAT; //isuusing LCM controlling idle status
LCDM_DPORT_IN; //data bus switching to input direction
}
unsigned char RdLCMStatus(void)
{
unsigned char lcmstatus;
CS_ENABLE; //chip selection enable
RD_LOW;
lcmstatus=LCDM_DAT_IN;//read into bus status
SwapOrder(&lcmstatus);
RD_HIGH;
LCDM_INIT_STAT; //isuusing LCM controlling idle status
return lcmstatus;
}
unsigned char RdLCMData(void)
{
unsigned char backdata;
LCDM_DATA; //LCM command register selected
CS_ENABLE; //chip selection enable
RD_LOW; //enable data to bus
backdata=LCDM_DAT_IN; //read into bus status
SwapOrder(&backdata);
RD_HIGH; //read signal valid
LCDM_INIT_STAT; //isuusing LCM controlling idle status
return backdata;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -