|
使用HSB1622 驱动断码管
#ifndef __HSB1622_C__
#define __HSB1622_C__
void Ht1621_Init(void)
{
/********************************************************
CS_HIGH; //HT1621_CS=1;
WR_HIGH; //HT1621_WR=1;
DATA_HIGH; //HT1621_DAT=1;
DelayMS(10);
Ht1621WrCmd(BIAS);
Ht1621WrCmd(RC256);
//Ht1621WrCmd(SYSDIS);
//Ht1621WrCmd(WDTDIS);
Ht1621WrCmd(SYSEN);
Ht1621WrCmd(LCDON);
//Ht1621WrOneNum(0x09,0x01);
//Ht1621WrCmd(LCDOFF);
*********************************************************/
/********************************************************/
CS_HIGH; //HT1621_CS=1;
WR_HIGH; //HT1621_WR=1;
DATA_HIGH; //HT1621_DAT=1;
DelayMS(10);
Ht1621WrCmd(NORMAL);
//Ht1621WrCmd(EXT32K);
Ht1621WrCmd(SYS_EN);
Ht1621WrCmd(LCD_ON);
Ht1621WrCmd(RC256);
// Ht1621WrCmd(EXT32K);
//Ht1621WrCmd(IRQ_EN);
Ht1621WrCmd(TIMER_EN);
//Ht1621WrCmd(F16);
//Ht1621WrCmd(TONE_ON);
//Ht1621WrCmd(TONE_2K);
void Ht1621Wr_Data(uchar Data,uchar cnt)
{
uchar i;
for (i=0;i<cnt;i++)
{
WR_LOW;
if((Data & 0x80))
DATA_HIGH;
else
DATA_LOW;
DelayUS(5);
WR_HIGH;
DelayUS(5);
Data<<=1;
DelayUS(5);
}
}
void Ht1621WrOneData(uchar Addr,uchar Data)
{
CS_LOW;
DelayUS(5);
Ht1621Wr_Data(0xa0,3);
DelayUS(5);
Ht1621Wr_Data(Addr<<2,6);
DelayUS(5);
Ht1621Wr_Data(Data<<4,4);
DelayUS(5);
CS_HIGH;
DelayUS(5);
}
void Ht1621WrOneNum(uchar Addr,uchar num)
{
CS_LOW;
DelayUS(5);
Ht1621Wr_Data(0xa0,3);
DelayUS(5);
Ht1621Wr_Data(Addr<<2,6);
DelayUS(5);
Ht1621Wr_Data(num,8);
DelayUS(5);
CS_HIGH;
DelayUS(5);
}
void Ht1621WrAllData(uchar Addr,uchar *p,uchar cnt)
{
static uchar i=0;
CS_LOW;
DelayUS(5);
Ht1621Wr_Data(0xa0,3);
DelayUS(5);
Ht1621Wr_Data(Addr<<2,6);
DelayUS(5);
for (i=0;i<cnt;i++)
{
Ht1621Wr_Data(*p,8);
DelayUS(1);
}
CS_HIGH;
DelayUS(5);
}
void Ht1621WrCmd(uchar Cmd)
{
CS_LOW; //HT1621_CS=0;
DelayUS(5);
Ht1621Wr_Data(0x80,4);
DelayUS(5);
Ht1621Wr_Data(Cmd,8);
DelayUS(5);
CS_HIGH; //HT1621_CS=1;
DelayUS(5);
}
#endif
|
|