keyboard.c

来自「将模拟温度传感器与数字转换接口电路集成在一起」· C语言 代码 · 共 72 行

C
72
字号
/*********************************************************************************************
* File:	8led.c
* Author:	embest	
* Desc:	8-segment digit LED control functions
* History:	
*********************************************************************************************/
#include "44b.h"
#include "44blib.h"
#include "def.h"
#include "iic.h"

/*------------------------------------------------------------------------------------------*/
/*	 								global variables					 				    */
/*------------------------------------------------------------------------------------------*/
int f_nKeyPress;
int num_key;

/*------------------------------------------------------------------------------------------*/
/*	 								function declare						 				    */
/*------------------------------------------------------------------------------------------*/
void keyboard_test(void);
void keyboard_int(void);

/*********************************************************************************************
* name:		keyboard_test
* func:		test 8led
* para:		none
* ret:		none
* modify:
* comment:		
********************************************************************************************/
void keyboard_test(void)
{
	int i, j, k;
	UINT8T ucChar, t;
	
	iic_init();
	
	// initiaze the 8led-function first of ZLG7290 (more to see ZLG7290.pdf)
	// precent the invalid sign generated while keyboard-function

	// set EINT2 interrupt handler
    pISR_EINT2 = (int)keyboard_int;

	for(;;)
	{
	    f_nKeyPress = 0;
		rINTMSK = rINTMSK & (~(BIT_GLOBAL|BIT_EINT2));		// enable EINT2 int
		while(f_nKeyPress == 0);
		iic_read(0x70, 0x1, &ucChar);
		if(ucChar != 0){
			uart_printf("press key %d\n", ucChar);
			num_key=ucChar;
		}	
	}
}

/*********************************************************************************************
* name:		keyboard_int
* func:		keyboard interrupt handler
* para:		none
* ret:		none
* modify:
* comment:		
********************************************************************************************/
void keyboard_int(void)
{
	rINTMSK = rINTMSK | BIT_EINT2;							// disable EINT2 int
    rI_ISPC = BIT_EINT2;
    f_nKeyPress = 1;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?