From 27b7177adf935135af60b935fe0701f7210ed3f7 Mon Sep 17 00:00:00 2001 From: arighi Date: Sat, 17 Apr 2010 15:04:24 +0000 Subject: [PATCH] lm3s1968: add keypad driver implementation to the example. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3447 38d2e660-2303-0410-9eaa-f027e97ec537 --- examples/lm3s1968/hw/hw_kbd.h | 66 ++++++++++++++++++++++++++++++++ examples/lm3s1968/hw/kbd_map.h | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 examples/lm3s1968/hw/hw_kbd.h create mode 100644 examples/lm3s1968/hw/kbd_map.h diff --git a/examples/lm3s1968/hw/hw_kbd.h b/examples/lm3s1968/hw/hw_kbd.h new file mode 100644 index 00000000..10562f79 --- /dev/null +++ b/examples/lm3s1968/hw/hw_kbd.h @@ -0,0 +1,66 @@ +/** + * \file + * + * + * \brief LM3S1968 keypad: hardware-specific definitions + * + * \author Andrea Righi + */ + +#ifndef HW_KBD_H +#define HW_KBD_H + +#include /* BV() */ +#include /* GPIO_PORTG_BASE */ +#include /* lm3s_gpioPinConfig() / lm3s_gpioPinRead() */ +#include "hw/kbd_map.h" + +#define K_RPT_MASK (K_UP | K_DOWN | K_LEFT | K_RIGHT | K_OK) + +#define KBD_HW_INIT \ + do { \ + lm3s_gpioPinConfig(GPIO_PORTG_BASE, \ + K_RPT_MASK, \ + GPIO_DIR_MODE_IN, \ + GPIO_STRENGTH_2MA, \ + GPIO_PIN_TYPE_STD_WPU); \ + } while (0) + +/** + * Read the keyboard ports and return the mask of depressed keys. + */ +INLINE keymask_t kbd_readkeys(void) +{ + return ~lm3s_gpioPinRead(GPIO_PORTG_BASE, + K_UP | K_DOWN | K_LEFT | K_RIGHT | K_OK); +} + +#endif /* HW_KBD_H */ diff --git a/examples/lm3s1968/hw/kbd_map.h b/examples/lm3s1968/hw/kbd_map.h new file mode 100644 index 00000000..a8efc919 --- /dev/null +++ b/examples/lm3s1968/hw/kbd_map.h @@ -0,0 +1,69 @@ +/** + * \file + * + * + * \brief Keyboard map definitions. + * + * \version $Id$ + * + * \author Francesco Sacchi + * \author Stefano Fedrigo + */ + +#ifndef HW_KBD_MAP_H +#define HW_KBD_MAP_H + +#include + +/** + * Type for keyboard mask. + */ +typedef uint16_t keymask_t; + +/** + * \name Keycodes. + */ +/*@{*/ +#define K_UP BV(3) +#define K_DOWN BV(4) +#define K_LEFT BV(5) +#define K_RIGHT BV(6) +#define K_OK BV(7) + +#define K_REPEAT BV(13) /**< This is a repeated keyevent. */ +#define K_TIMEOUT BV(14) /**< Fake key event for timeouts. */ +#define K_LONG BV(15) +/*@}*/ + +#define K_LNG_MASK 0 + +#endif /* HW_KBD_MAP_H */ -- 2.25.1