/******************************************************************************************************************* *File Name : keyPort.h *Description : the file is cpu privatie key port *Date : 2008/06/13 *Author : yuanguiyou --History: ------------------------------------------------------------------------------------------------------------------ *change info: *******************************************************************************************************************/ #include "../includes.h" #include "keyPort.h" void KeyInitPort(void) /* Initialize I/O ports */ { KEY_PORT_CW = 0xF0; KEY_PORT_ROW = 0xFF; } uint8_t KeyGetCol(void) /* Read COLUMNs */ { return (~(inp(KEY_PORT_COL)&0x0F)); } void KeySelRow(uint8_t ucRow) /* Select a ROW */ { if (ucRow == KEY_ALL_ROWS) { outp(KEY_PORT_ROW, 0x0F); /* Force all rows LOW */ } else { ucRow += 4; outp(KEY_PORT_ROW, ~(1 << ucRow)); /* Force desired row LOW */ } }