有关7279键盘驱动芯片程序C语言

有关7279键盘驱动芯片程序C语言,第1张

默认11.0592Mhz的晶振。

—————————————————————*/

#include <reg51.h>

/*--------------------------------------------

调用方式:自行I/O 口定义﹫2001/05/12

函数说明:私有函数,各接口定义

--------------------------------------------*/

sbit HD7279_CS=P1^4// HD7279_CS--P1.4

sbit HD7279_CLK=P1^5// HD7279_CLK-- P1.5

sbit HD7279_DATA=P1^6// HD7279_DATA-- P1.2

sbit HD7279_KEY =P1^7// HD7279_KEY-- P1.3

/*--------------------------------------------

调用方式: HD7279A 各指令定义﹫2001/05/12

函数说明:私有函数,接口定义

--------------------------------------------*

/#define HD7279_RESET 0xa4 //复位

#define HD7279_TEST 0xbf //测试

#define HD7279_RLC 0xa3 //循环左移

#define HD7279_RRC 0xa2 //循环右移

#define HD7279_RL 0xa1 //左移

#define HD7279_RR 0xa0 //右移

#define HD7279_DECODE0 0x80 //译码方式0

#define HD7279_DECODE1 0xc8 //译码方式1

#define HD7279_UNDECODE 0x90 //译码方式2: 不译码

#define HD7279_HIDE 0x98 //消隐

#define HD7279_FLASH 0x88 //闪烁

#define HD7279_SEGON 0xe0 //段亮

#define HD7279_SEGOFF 0xc0 //段灭

#define HD7279_READ 0x15 //读

/*--------------------------------------------

调用方式: void HD7279_LongDelay(void) 等侍函数﹫2001/05/12

函数说明 私有函数,>500ms

--------------------------------------------*/

void HD7279_LongDelay(void)

{

unsigned char i

for (i=0i<6i++)

}

/*--------------------------------------------

调用方式:void HD7279_ShortDelay(void) 等侍函数﹫2001/05/12

函数说明:私有函数,=500ms

--------------------------------------------*

/void HD7279_ShortDelay(void)

{}

/*--------------------------------------------

调用方式:void Delay10ms(unsigned char time) 等侍函数﹫2001/05/12

函数说明:私有函数, 6M晶振

--------------------------------------------*/

void Delay10ms(unsigned char time)

{

unsigned char i

unsigned int j

for(i=0i<timei++)

{

for(j=0j<931j++)

{}

}

}

/*--------------------------------------------

调用方式:void HD7279_ShortDelay(void) 函数﹫2001/05/12

函数说明:私有函数,送指令

--------------------------------------------*/

void HD7279_SendByte( unsigned char out_byte)

{

unsigned char i

HD7279_CS=0

HD7279_LongDelay()

for(i=0i<8i++)

{

if(out_byte&0x80) { HD7279_DATA=1}

else { HD7279_DATA=0}

HD7279_CLK=1

HD7279_ShortDelay()

HD7279_CLK=0

HD7279_ShortDelay()

out_byte=out_byte<<1

}

HD7279_DATA=0

}

/*--------------------------------------------

调用方式:void Write7279(unsigned char command,unsigned char dta) 函数﹫2001/05/12

函数说明:私有函数,写函数

--------------------------------------------*/

void Write7279(unsigned char command, unsigned char dta)

{

HD7279_SendByte( command )

HD7279_SendByte( dta )

}

/*--------------------------------------------

调用方式:自定义函数﹫2001/05/12

函数说明:私有函数,自行定义

--------------------------------------------*/

#define RunKey 0xXX

#define StopKey 0xXX

/*--------------------------------------------

调用方式:unsigned charHD7279_ReceiveByte(void)函数﹫2001/05/12

函数说明:私有函数,接受一个BYTE函数

--------------------------------------------*/

unsigned char HD7279_ReceiveByte(void)

{

unsigned char i, in_byte

HD7279_DATA=1

HD7279_LongDelay()

for(i=0i<8i++)

{HD7279_CLK=1<br>HD7279_ShortDelay()<br>in_byte=in_byte<<1<br>if(HD7279_DATA) { in_byte=in_byte|0x01}

HD7279_CLK=0

HD7279_ShortDelay()

}

HD7279_DATA=0

return (in_byte)

}

/*--------------------------------------------

调用方式:unsigned char HD7279_GetKey()函数﹫2001/05/12

函数说明:私有函数,读键盘函数

--------------------------------------------*/

unsigned char HD7279_GetKey()

{

unsigned char key

if(!HD7279_KEY)

{

HD7279_SendByte(HD7279_READ)

key=HD7279_ReceiveByte()

switch( key )

{case RunKey: <br>case StopKey: <br>while(!HD7279_KEY)<br>default: return(0xff)<br>}

}

return(0xff)

}

/*--------------------------------------------

调用方式:main()函数﹫2001/05/12

函数说明:私有函数,例函数

--------------------------------------------*/

main()

{HD7279_SendByte(0xa4)//复位<br>Write7279(0x80,0)//显示‘0’<br>}

The diesel engine fuel oil consumption rate weighs the diesel engine itself fuel oil efficient most important target.Also is the diesel engine performance important technical parameter, the diesel engine fuel oil consumption rate tradition measuring technique cannot carry on the survey under the ships navigation condition.Therefore sought with the software establishment survey oil consumption meter procedure innovation method had the theory and practical significance

this article introduced introduced the monolithic integrated circuit development general picture and the MCS-96 monolithic integrated circuit performance characteristic, and has carried on controls the chip take 80C196KC, as assisted the chip take 74 series, fixed time counted take the double-current gauge as the measuring technique diesel engine fuel oil consumption software the procedure and the HD7279A test order establishment.

In has completed in the software fixed time procedure foundation, has discussed, how enhances the development entire procedure the working efficiency, with monolithic integrated circuit performance method.And has completed the program debugging and the modelling.The experiment indicated that, the C language procedure may enhance the entire procedure effectively the working efficiency, moreover is helpful to fully displays the performance which the monolithic integrated circuit processor enhances day by day


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11192742.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存