/* keypad.h - 4x4 matrix keypad driver.
 * Copyright 2008 Colin D. Bennett <colin@gibibit.com>.
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 */
#ifndef DRAGON12_KEYPAD_H_
#define DRAGON12_KEYPAD_H_

#include <stdint.h>

/*
 * Initialize the matrix keypad port (Port A).
 * The matrix keypad uses the entire port A.
 */
void keypad_init(void);


/* 
 * Get the scan code of the currently pressed key on the matrix keypad.
 * This function does not properly detect simultaneous multiple key presses.
 * The scancode is 0..3 for the top row, and proceeding row-wise down:
 *   
 *    0  1  2  3
 *    4  5  6  7
 *    8  9 10 11
 *   12 13 14 15
 *
 * Returns:  The scan code of the currently pressed key,
 *           or -1 if no key is currently pressed.
 */
int8_t keypad_read_scancode(void);

#endif /* DRAGON12_KEYPAD_H_ */

