📄 ht1621.c
字号:
/*******************************************************************************
** (c) Copyright 2004-2005, xujiajun
** All Rights Reserved
** V040723
**--------------文件信息--------------------------------------------------------
**创 建 人: 徐家俊
**创建日期: 2006年1月20日
**描 述:HT1621驱动
**--------------版本修订历史----------------------------------------------------
** 修改人:徐家俊
** 版 本: V
** 日 期: 年月日
** 描 述:
**--------------当前版本修订----------------------------------------------------
** 修改人:徐家俊
** 版 本:
** 日 期:年月日
** 描 述:
**------------------------------------------------------------------------------
*******************************************************************************/
//#define IN_1621
#include"main.h"
/*----------------------------------------------------------------------------*/
//const define
#define BIAS 0X52 /*定义1 3 偏压4 背极*/
#define XTAL32 0X28 /*使用外部晶振*/
#define RC256 0X30 /*使用内部256KRC 振荡器*/
#define SYSEN 0X02 /*打开振荡发生器*/
#define LCDON 0X06 /*打开LCD*/
#define SYSDIS 0X00 /*关闭振荡发生器*/
#define LCDOFF 0X04 /*显示关闭*/
#define TONE4 0X80 /*设置BZ 输出频率为4K*/
#define TONEON 0X12 /*打开BZ 音频输出*/
#define TONEOFF 0X10 /*关闭BZ 音频输出*/
#define CLRWDT 0X1c /*清零WDT*/
#define F1 0X40 /*WDT设置为4 秒溢出*/
#define IRQEN 0X10 /*IRQ 输出禁止*/
#define IRQDIS 0X00 /*IRQ 输出允许*/
#define WDTEN 0X0e /*打开WDT*/
#define WDTDIS 0X0a /*关闭WDT*/
#define TIMERDIS 0X08 /*关闭时基输出*/
/*----------------------------------------------------------------------------*/
//Globe variable define
/*----------------------------------------------------------------------------*/
//function define
void FillSameDataTo1621(uchar Data);
/********************************************************************************************************
Descriptions: 发送数据位
input parameters: bitcnt : the bits of being sent
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
void SendBit(uchar dat,uchar bitcnt)
{
uchar i;
for(i=0;i<bitcnt;i++)
{
if(( dat & 0x80 ) == 0)
HT1621Data_Port = 0;
else
HT1621Data_Port = 1; /*发送数据由高位到低位传送*/
_nop_();
_nop_();
HT1621Wr_Port = 1; /*置写时钟线为高通知被控器开始接收数位*/
_nop_();
_nop_();
HT1621Wr_Port = 0; /*钳住总线准备下一个数据位*/
dat=dat<<1; /*发送数据左移一位*/
}
}
/********************************************************************************************************
Descriptions: 发送A命令函数 发送HT1621 命令时要先发送ID 值
input parameters: command
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
void SendComA(uchar command)
{
HT1621Wr_Port = 1;
HT1621Cs_Port = 0;
_nop_();
HT1621Wr_Port = 0;
SendBit(0x80,4);/*发送设置命令ID=100 0*/
SendBit(command, 8);/*发送命令字*/
HT1621Cs_Port = 1;
HT1621Wr_Port = 1;
}
/********************************************************************************************************
Descriptions: 发送B命令函数 发送HT1621 命令时要先发送ID 值
input parameters: command
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
/*
void SendComB(uchar command)
{
HT1621Wr_Port = 1;
HT1621Cs_Port = 0;
_nop_();
HT1621Wr_Port = 0;
SendBit(0x90,4);//发送设置命令ID=100 1
SendBit(command, 8);//发送命令字
HT1621Cs_Port = 1;
HT1621Wr_Port = 1;
}
*/
/********************************************************************************************************
Descriptions: initial HT1621
input parameters: None
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
void HT1621Init(void)
{
HT1621Data_Port = 1;
HT1621Cs_Port = 1;
HT1621Wr_Port = 1;
SendComA(b00000010B);//开系统振荡器
SendComA(b00000110B);//打开LCD偏压发生器
SendComA(b00110000B);//系统时钟片内振荡器
SendComA(b01010010B);//最后一位1/2或1/3偏压
SendComA(b00010000B);//关闭声音输出
SendComA(b10000000B);//声音4Kkz
FillSameDataTo1621(0); /*输出全显数据*/
//清HT1621显示数据
ucLCDData1 = LCD_DB_NC;
ucLCDData2 = LCD_NC;
ucLCDData3 = LCD_NC;
ucLCDData4 = LCD_NC;
ucLCDData5 = LCD_NC;
ucLCDData6 = LCD_NC;
ucLCDSegment1 = 0;
ucLCDSegment2 = 0;
}
/********************************************************************************************************
Descriptions: send data to HT1621
input parameters: pBuf:the data buf point; Addr:the address of the data; DataCnt:the number of data
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
/*
void Send1621Data(uchar* pBuf, uchar Addr, uchar DataCnt)
{
uchar i;
HT1621Wr_Port = 1;
HT1621Cs_Port = 0;
_nop_();
HT1621Wr_Port = 0;
SendBit(0xA0, 3);//send the prefix 101
Addr <<= 2;
SendBit(Addr, 6);//send the addr
for(i=0;i<DataCnt;i++)
{
SendBit(*pBuf, 8);//send the data
pBuf++;
}
HT1621Cs_Port = 1;
HT1621Wr_Port = 1;
}
*/
/********************************************************************************************************
Descriptions: fill the same data to HT1621
input parameters: data
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
void FillSameDataTo1621(uchar Data)
{
uchar i;
HT1621Wr_Port = 1;
HT1621Cs_Port = 0;
_nop_();
HT1621Wr_Port = 0;
SendBit(0xA0, 3);//send the prefix 101
SendBit(0x00, 6);//send the addr
for(i=0;i<16;i++)
{
SendBit(Data, 8);//send the data
}
HT1621Cs_Port = 1;
HT1621Wr_Port = 1;
}
/********************************************************************************************************
Descriptions: Get the time in PCF8563 and show on LCD controled by HT1621
;接收并在LCD上显示时间 DISP_TIME_ON_LCD
input parameters: data
Returned value: None
Used global variables: None
Calling modules: None
Created by: xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
Modified by:
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -