keyboard.c

来自「Embest EudKit-II教学系统配Samsung S3C44B0处理器的」· C语言 代码 · 共 75 行

C
75
字号
/*********************************************************************************************
* 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;

/*------------------------------------------------------------------------------------------*/
/*	 								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
	for(i=0; i<8; i++)
		iic_write(0x70, 0x10+i, 0xFE);

	// 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);
	}
    
    while(1);
}

/*********************************************************************************************
* name:		keyboard_int
* func:		keyboard interrupt handler
* para:		none
* ret:		none
* modify:
* comment:		
********************************************************************************************/
void keyboard_int(void)
{
	UINT8T ucChar;

	rINTMSK = rINTMSK | BIT_EINT2;							// disable EINT2 int
    rI_ISPC = BIT_EINT2;
    f_nKeyPress = 1;
}

⌨️ 快捷键说明

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