From: aleph Date: Wed, 2 Mar 2011 15:50:39 +0000 (+0000) Subject: sam3x-ek board: keyboard definitions for "left click" and "right click" switches X-Git-Tag: 2.7.0~228 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=1ce7810b3c528ca5fabaa8a08cd16ca4e65596c9;p=bertos.git sam3x-ek board: keyboard definitions for "left click" and "right click" switches git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4738 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/boards/sam3x-ek/hw/hw_kbd.h b/boards/sam3x-ek/hw/hw_kbd.h new file mode 100644 index 00000000..4913b8b4 --- /dev/null +++ b/boards/sam3x-ek/hw/hw_kbd.h @@ -0,0 +1,75 @@ +/** + * \file + * + * + * \brief SAM3X-EK keypad: hardware-specific definitions + * + * \author Stefano Fedrigo + */ + +#ifndef HW_KBD_H +#define HW_KBD_H + +#include /* BV() */ +#include +#include "hw/kbd_map.h" + +#define KBD_LEFT_PIN BV(7) // Port E +#define KBD_RIGHT_PIN BV(23) // Port B + +#define K_RPT_MASK (K_LEFT | K_RIGHT) + +#define KBD_HW_INIT \ + do { \ + PIOE_IDR = KBD_LEFT_PIN; \ + PIOE_PUER = KBD_LEFT_PIN; \ + PIOE_ODR = KBD_LEFT_PIN; \ + PIOE_PER = KBD_LEFT_PIN; \ + PIOB_IDR = KBD_RIGHT_PIN; \ + PIOB_PUER = KBD_RIGHT_PIN; \ + PIOB_ODR = KBD_RIGHT_PIN; \ + PIOB_PER = KBD_RIGHT_PIN; \ + } while (0) + +/** + * Read the keyboard ports and return the mask of depressed keys. + */ +INLINE keymask_t kbd_readkeys(void) +{ + keymask_t mask = 0; + if (!(PIOE_PDSR & KBD_LEFT_PIN)) + mask |= K_LEFT; + if (!(PIOB_PDSR & KBD_RIGHT_PIN)) + mask |= K_RIGHT; + return mask; +} + +#endif /* HW_KBD_H */ diff --git a/boards/sam3x-ek/hw/kbd_map.h b/boards/sam3x-ek/hw/kbd_map.h new file mode 100644 index 00000000..83141ade --- /dev/null +++ b/boards/sam3x-ek/hw/kbd_map.h @@ -0,0 +1,69 @@ +/** + * \file + * + * + * \brief SAM3X-EK keyboard map definitions. + * + * \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_LEFT BV(0) +#define K_RIGHT BV(1) + +#define K_DOWN K_LEFT +#define K_OK K_RIGHT +#define K_UP BV(2) // Not used, defined to please menu.c +#define K_CANCEL BV(3) // Not used, defined to please menu.c + +#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 */