📄 keypad.c
字号:
//=====================================================================
// TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
// Property of Texas Instruments -- For Unrestricted Internal Use Only
// Unauthorized reproduction and/or distribution is strictly prohibited
// This product is protected under copyright law and trade secret law as
// an unpublished work.Created 1987,(C) Copyright 1997 Texas Instruments.
// All rights reserved.
//=====================================================================
// Description : keypad interface
//
// Project : Helen
//
// Author : Laurent Delahaye (STUDIEL)
//===============================================================================
#include "global_types.h"
#include "armio32.h"
extern UWORD32 loop_wait;
#define KP_ROWS 5
#define KP_COLS 6
const char keypad[KP_ROWS][KP_COLS]=
{ // Electrical & physical
{'c','-',' ','^',' ',' '}, // row 0 (highest)
{'1','2','*','3',' ',' '}, // row 1
{'7','8','0','9',' ',' '}, // row 2
{'4','5','#','6',' ',' '}, // row 3
{'<','>',' ','v',' ',' '}, // row 4 (lowest)
};
char KEYP_KeypadRead(void)
{
UWORD8 row;
UWORD8 col;
UWORD8 row_number;
UWORD8 col_number;
UWORD8 save_row;
UWORD8 read_row;
UWORD8 col_value=0x01;
save_row = (ARMIO_GET_ALL_KBROW() & 0x1F);
// Row identification
for (row_number=0 ; row_number<KP_ROWS ; row_number++)
{
if (ARMIO_GET_BIT_KBROW(row_number) == 0)
{
row = row_number;
}
}
// Column identification
for (col_number=0 ; col_number<KP_COLS ; col_number++)
{
ARMIO_SET_ALL_KBCOL(~(col_value << col_number)); // Write a 0 on the processed columns and a 1 on the others
for(loop_wait=0; loop_wait<0x10; loop_wait++); // Wait for stable status
read_row = (ARMIO_GET_ALL_KBROW() & 0x1F); // Read rows status
if (read_row == save_row) // Rows status is the same than the beginning ?
{
col = col_number;
}
}
// Set ouput colums to 0
ARMIO_SET_ALL_KBCOL(0x00);
return(keypad[row][col]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -