首页 | 最新需求 | 最新现货 | IC库存 | 供应商 | IC英文资料库 | IC中文资料库 | IC价格 | 电路图 | 应用资料 | 技术资料
 电路图:    3万份资料
您现在的位置:首页 >  电路图 芯片中文资料列表  
 
 
介绍:

ht1621 c程序

Ht1621中文资料   Ht1621pdf

LCD驱动HT1621
#include <reg51.h>
#include <types.h>
#include <intrins.h>
#include <bin.h>
extern BOOL PIN_1621_CS;
extern BOOL PIN_1621_DAT;
extern BOOL PIN_1621_WR;
#define CLK_DELAY() {_nop_(); _nop_(); _nop_();}
//--------------------------------------------------------------------------
// Name: Write_1621_RAM
//--------------------------------------------------------------------------
void Write_1621_RAM(BYTE addr, BYTE idata *buf, BYTE size){
BYTE i,j;
BYTE tmp;
PIN_1621_CS = 1; // clear CS
CLK_DELAY();
PIN_1621_CS = 0; // clear CS
// CMD - 101
tmp = B0000_0101;
for (i=3; i>0; --i){
PIN_1621_DAT = tmp & 0x04; tmp <<= 1;
PIN_1621_WR = 0; CLK_DELAY();
PIN_1621_WR = 1; CLK_DELAY();
}
// Addr - 0x00
tmp = addr & B0011_1111;
for (i=6; i>0; --i){
PIN_1621_DAT = tmp & 0x04; tmp <<= 1;
PIN_1621_WR = 0; CLK_DELAY();
PIN_1621_WR = 1; CLK_DELAY();
}
// data - successive 32 bytes
for (j=size; j>0; --j){
tmp = *buf;
for (i=8; i>0; --i){
PIN_1621_DAT = tmp & 0x01; tmp >>= 1;
PIN_1621_WR = 0; CLK_DELAY();
PIN_1621_WR = 1; CLK_DELAY();
}
buf ++;
}
}
//--------------------------------------------------------------------------
// Name: Write_1621_COMMAND
//--------------------------------------------------------------------------
static void Write_1621_COMMAND(BYTE config){
BYTE i;
BYTE cmd;
PIN_1621_CS = 1; // clear CS
CLK_DELAY();
PIN_1621_CS = 0; // clear CS
cmd = B0000_0100;
// CMD - 110
for (i=3; i>0; --i){
PIN_1621_DAT = cmd & 0x04; cmd <<= 1;
PIN_1621_WR = 0; CLK_DELAY();
PIN_1621_WR = 1; CLK_DELAY();
}
// config
for (i=9; i>0; --i){
PIN_1621_DAT = config & 0x80; config <<= 1;
PIN_1621_WR = 0; CLK_DELAY();
PIN_1621_WR = 1; CLK_DELAY();
}
}
//--------------------------------------------------------------------------
// Name: Init_1621
//--------------------------------------------------------------------------
void Init_1621(void){
Write_1621_COMMAND(B0010_1001); // 4 comm
Write_1621_COMMAND(B0000_0011); // Turn On LCD
Write_1621_COMMAND(B0000_0001); // Enable System
}
//--------------------------------------------------------------------------
// Name: TurnOn_1621
//--------------------------------------------------------------------------
void TurnOn_1621(BOOL bOnoff){
if (bOnoff){
Write_1621_COMMAND(B0000_0011); // bias generator
}
else {
Write_1621_COMMAND(B0000_0010); // bias generator
}
}
//-------------------------------------------------------------------------
// M62446 drving routines, VER 1.0
//
// COPYRIGHT (C) 2000, Enbia Technology Inc.
// Target: 8031
// AUTHOR: STEVEN LUO
//
// Revision History:
// 2001/1/5 - Original Version
//
//-------------------------------------------------------------------------
#include <reg51.h>
#include <types.h>
#include <intrins.h>
#include <bin.h>
extern BOOL PIN_M62446_LATCH;
extern BOOL PIN_M62446_DATA;
extern BOOL PIN_M62446_CLK;
static idata WORD shadow_word00=0;
static idata WORD shadow_word01=0;
static idata WORD shadow_word10=0;
static idata WORD shadow_word11=0; // for storing the control word status //
static BOOL bM62446Muted; // Set when 62446 is muted
static void Write_M62446_Word(WORD myword);
//-------------------------------------------------------------------------
// Name: Volume_Validate
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
static BYTE Volume_Validate(char vol){
if(vol<0)vol=0; // negative, should be 0
else if(vol >80) vol=80; // >80, set to 80
return 80 - vol; // Down to Up
}
//-------------------------------------------------------------------------
// Name: Mute_M62446
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Mute_M62446(void){
Write_M62446_Word(0xa141); // B1010000 1010000 01, B10100001_01000001
Write_M62446_Word(0xa142);
Write_M62446_Word(0xa143);
bM62446Muted = 1;
}
//-------------------------------------------------------------------------
// Name: UnMute_M62446
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void UnMute_M62446(void){
shadow_word01&=0xfffc; shadow_word01|=0x01; Write_M62446_Word(shadow_word01);
shadow_word10&=0xfffc; shadow_word10|=0x02; Write_M62446_Word(shadow_word10);
shadow_word11&=0xfffc; shadow_word11|=0x03; Write_M62446_Word(shadow_word11);
bM62446Muted = 0;
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Left
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Left(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word01&=0x01ff;
shadow_word01|=temp;
// DE=0;DF=1;
shadow_word01&=0xfffc; shadow_word01|=0x01;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word01);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Right
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Right(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=2;
shadow_word01&=0xfe03;
shadow_word01|=temp;
// DE=0;DF=1;
shadow_word01&=0xfffc; shadow_word01|=0x01;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word01);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Center
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Center(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word10&=0x01ff;
shadow_word10|=temp;
// DE=1;DF=0;
shadow_word10&=0xfffc; shadow_word10|=0x02;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word10);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_SubWoofer
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_SubWoofer(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=2;
shadow_word10&=0xfe03;
shadow_word10|=temp;
// DE=1;DF=0;
shadow_word10&=0xfffc; shadow_word10|=0x02;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word10);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_SurLeft
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_SurLeft(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word11&=0x01ff;
shadow_wor

 
 

更多 110
关于我们 | 联系我们 | IC列表库索引1 | IC列表库索引2 | IC列表库索引3 | IC列表库索引4 |
深  圳13410210660             QQ : 84325569   点击这里与集成电路资料查询网联系
联系方式: E-mail:CaiZH01@163.com