⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st7565.c

📁 用于MSP430169驱动12864的液晶显示器
💻 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;    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -