?? ht1621.c
字號:
#include "target.h"
/*
HT1621.c--low level driver for HT1621 or
other Lcd driver chip.
version 1.0.1,Jun 28th,2003
Copyright (C) 2002-2003 Mcu Life Co.Ltd.
Designed by Victor.li,If you have anyquestion,please connect me by follow:
http://yiyun2000.myrice.com
email:yunhongli@21cn.com
*/
/*
BIAS & COM 1 0 0 0 0 1 0 a b X c X
c=0: 1/2 bias option
c=1: 1/3 bias option
ab=00: 2 commons option
ab=01: 3 commons option
ab=10: 4 commons option
*/
#define BIAS_1_3 0x52
#define READ_COMMAND 0X180
#define WRITE_COMMAND 0X140
#define READ_MODIFIED_WRITE_COMMAND 0X140
#define LCD_COMMAND 0X0800
enum{
DIS_LCD = 0x0000, //Turn off both system oscillator and LCD bias generator
EN_LCD = 0x0002, //Turn on system oscillator
OFF_LCD = 0x0004, //Turn off LCD display
ON_LCD = 0x0006, //Turn on LCD display
TIMER_DIS_LCD = 0x0008, //Disable time base output
DIS_WDT_LCD = 0x000A, //Disable WDT time-out flag output
TIMER_EN_LCD = 0x000C, //Enable time base output
EN_WDT_LCD = 0x000E, //Enable WDT time-out flag output
TONE_OFF_LCD = 0x0010, //Turn off Tone output
TIMER_LCD = 0x001A, //Clear the contents of the time base generator
WDT_LCD = 0x001E, //Clear the contents of WDT stage
RC_32K_LCD = 0x0030, //System clock source,on-chip RC oscillator
EXT_32K_LCD = 0x0038, //System clock source,external clock source
TONE_4K_LCD = 0x0080, //Tone frequency output:4kHz
TONE_2K_LCD = 0x00C0, //Tone frequency output:2kHz
IRQ_DIS_LCD = 0x0100, //Disable IRQ output
IRQ_EN_LCD = 0x0110 //Enable IRQ output
};
#define Set_Lcd_CS() Set_P1_7()
#define Clr_Lcd_CS() Clr_P1_7()
#define Set_Lcd_WR() Set_P1_6()
#define Clr_Lcd_WR() Clr_P1_6()
#define Set_Lcd_DATA() Set_P1_5()
#define Clr_Lcd_DATA() Clr_P1_5()
//define for lcd delay time,it should
#define LCD_DELAY_COUNT 3
unsigned short code LcdMask[16] = {
0x01,0x02,0x04,0x08,
0x10,0x20,0x40,0x80,
0x100,0x200,0x400,0x800,
0x1000,0x2000,0x4000,0x8000
};
void LcdDelay()
{
char i;
for(i=0;i<LCD_DELAY_COUNT;i++);
}
void SendLcdBits(unsigned int com,unsigned char bitsnum)
{
char i;
for(i=bitsnum-1;i>=0;i--){
Clr_Lcd_WR();
LcdDelay();
if(com&LcdMask[i])
Set_Lcd_DATA();
else
Clr_Lcd_DATA();
LcdDelay();
Set_Lcd_WR();
LcdDelay();
}
}
void SendLcdSegData(unsigned char lcddata,unsigned char bitsnum)
{
unsigned char i;
for(i=0;i<bitsnum;i++){
Clr_Lcd_WR();
LcdDelay();
if(lcddata&(unsigned char)(LcdMask[i]))
Set_Lcd_DATA();
else
Clr_Lcd_DATA();
LcdDelay();
Set_Lcd_WR();
LcdDelay();
}
}
void SendLcdCommand(unsigned int com)
{
Set_Lcd_CS();
Set_Lcd_WR();
Set_Lcd_DATA();
Clr_Lcd_CS();
LcdDelay();
SendLcdBits(((com&0x1ff)|LCD_COMMAND),12);
Set_Lcd_CS();
}
void WriteLcdData(unsigned char addr,unsigned char ucdata)
{
unsigned int command;
addr <<= 1;
command = (addr&0x3f)|WRITE_COMMAND;
Clr_Lcd_CS();
LcdDelay();
SendLcdBits(command,9);
SendLcdSegData(ucdata,8);
Set_Lcd_CS();
}
void InitHT1621()
{
SendLcdCommand(ON_LCD);
SendLcdCommand(EN_LCD);
SendLcdCommand(BIAS_1_3);
}
void SetHT1621()
{
Set_Lcd_CS();
Set_Lcd_WR();
Set_Lcd_DATA();
}
void ClrHT1621()
{
Clr_Lcd_CS();
Clr_Lcd_WR();
Clr_Lcd_DATA();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -