📄 6961.c
字号:
/********************************************************************
*
* 模 块 名:显示模块 型号:PT6961
*
* 创 建 人:yingjiangan 日期:2008-03-04
* 修 改 人: 日期:2000-00-00
* 功能描述:
* 其他说明:
* 版 本:V1.0
**********************************************************************/
/************头文件************/
#include <intrins.h>
#include <sm5964.h>
#include "my_type.h"
#include "6961.h"
uint8 dsplay_dat[6];
uint8 dsplay_dot[6];
uint8 no_row;
/*********************************************************************
*
* 函 数 名: Dsplay
* 功能描述: 6961显示
* 函数说明:
* 输 入: p_dsp_dat数码管显示的数组指针,p_dsp_dot二极管显示执
* 返 回: 无
* 设 计 者:ying 日期:2008-03-07
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
void Dsplay()
{
uint8 dsplay_table[64]=
{0x3F, 0x12, 0x4F, 0x5B, 0x72, 0x79, 0x7D, 0x13,
// 0 1 2 3 4 5 6 7
0x7F, 0x7B, 0x77, 0x7C, 0x4C, 0x5E, 0x6D, 0x65,
// 8 9 A B C D E F
0x76, 0x10, 0x1A, 0x64, 0x2C, 0x55, 0x54, 0x5C,
// H I J K L M N O
0x67, 0x00, 0x44, 0x6C, 0x3E, 0x7A, 0x40, 0x00,
// P W R T U Y -
0xBF, 0x92, 0xCF, 0xDB, 0xF2, 0xF9, 0xFD, 0x93,
// 0. 1. 2. 3. 4. 5. 6. 7.
0xFF, 0xFB, 0xF7, 0xFC, 0xCC, 0xDE, 0xED, 0xE5,
// 8. 9. A. B. C. D. E. F.
0xF6, 0x90, 0x9A, 0xE4, 0xAC, 0xD5, 0xD4, 0xDC,
// H. I. J. K. L. M. N. O.
0xE7, 0x80, 0xC4, 0xEE, 0xBE, 0xFA, 0xC0, 0x80 };
// P. W. R. T. U. Y. -. .
uint8 *p_dsp_dat;
uint8 *p_dsp_dot;
uint8 *p_dsp_table;
p_dsp_dat=dsplay_dat;
p_dsp_dot=dsplay_dot;
p_dsp_table=dsplay_table;
Set_6961();
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+4)));//5
Write_6961_data(*(p_dsp_dot + 4));
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+5)));//6
Write_6961_data(*(p_dsp_dot + 5));
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+2)));//3
Write_6961_data(*(p_dsp_dot + 2));
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+3)));//4
Write_6961_data(*(p_dsp_dot + 3));
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+0)));//1
Write_6961_data(*(p_dsp_dot + 0));
Write_6961_data(*(p_dsp_table + *(p_dsp_dat+1)));//2
Write_6961_data(*(p_dsp_dot + 1));
}
/*********************************************************************
*
* 函 数 名: Set_6961
* 功能描述: 6961初始化
* 函数说明:
* 输 入: 无
* 返 回: 无
* 设 计 者:ying 日期:2008-03-05
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
void Set_6961(void)
{
Write_6961_cmd(0x02);//显示模式6位12段
Write_6961_cmd(0x40);//设置数据读写 00写、10读键扫
Write_6961_cmd(0xc0);//地址设定
Write_6961_cmd(0x89);//消光度设置
}
/*********************************************************************
*
* 函 数 名: Read_key_6961
* 功能描述: 读出6961键扫值
* 函数说明: 功能层
* 输 入: 无
* 返 回: 键值
* 设 计 者:ying 日期:2008-03-19
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
uint8 Read_key_6961()
{
uint8 i,r_data;
Write_6961_cmd(0x42);
for(i=0;i<=3;i++)
{
r_data=Read_6961();
r_data&=0x3f;
if (r_data)
{
no_row=i;
break;
}
else
{
no_row=0x00;
r_data=0x00;
}
}
return(r_data);
}
/*********************************************************************
*
* 函 数 名: key_value
* 功能描述: 读出6961键值
* 函数说明: 功能层
* 输 入: 无
* 返 回: 键值
* 设 计 者:ying 日期:2008-03-20
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
uint8 Key_value()
{
uint8 idata key_table[30]=
{ 0x07,0x04,0x01,0x0b,0x05,0x02,
0x08,0x06,0x03,0x0a,0x09,0x0d,
0x0c,0x0e,0x12,0x11,0x0f,0x13,
0x15,0x14,0x16,0x19,0x18,0x17 };
uint8 temp,add,i,j,*p4;
bit low;
p4=key_table;
temp=Read_key_6961();
add=no_row;
if(temp)
{
for(i=0;i<=6;i++)
{
low=temp&0x01;
if (low)
{
j=i;
break;
}
temp>>=1;
}
temp=6*add+j;
temp=*(p4+temp);
}
else
{
temp=0x00;
}
return(temp);
}
/*********************************************************************
*
* 函 数 名: Write_6961_cmd
* 功能描述: 写入6961一个字节命令
* 函数说明: 物理层 6961将SCL下降沿后的第一个字节做为命令
* 输 入: 要写入的命令
* 返 回: 无
* 设 计 者:ying 日期:2008-03-05
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
void Write_6961_cmd(uint8 cmd)
{
PT6961_RESET;
Write_6961_data(cmd);
}
/*********************************************************************
*
* 函 数 名: Write_6961_data
* 功能描述: 写入6961一个字节数据
* 函数说明: 物理层
* 输 入: 要写入的数据
* 返 回: 无
* 设 计 者:ying 日期:2008-03-04
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
void Write_6961_data(uint8 temp)
{
uint8 i;
for(i=0;i<8;i++)
{
DIO=temp&LSB;
CLK=0;
temp>>=1;
CLK=1;
}
}
/*********************************************************************
*
* 函 数 名: Read_6961
* 功能描述: 读6961数据
* 函数说明: 物理层
* 输 入: 要读出的地址
* 返 回: 无
* 设 计 者:ying 日期:2008-03-04
* 修 改 者:ying 日期:2000-00-00
***********************************************************************/
uint8 Read_6961()
{
uint8 i,temp=0x00;
DIO=1;
for (i=0;i<7;i++) //循环7次 读取数据
{
CLK=0;
if(DIO)
{
temp|=0x80; //每次传输低字节
}
CLK=1;
temp>>=1; //右移一位
}
CLK=0;
CLK=1;
return (temp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -